home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Unsorted BBS Collection
/
thegreatunsorted.tar
/
thegreatunsorted
/
programming
/
misc_programming
/
batnmore.z!p
/
MAN.BTM
< prev
next >
Wrap
Text File
|
1992-11-15
|
3KB
|
78 lines
*REM This batch file is Freeware, free to use and redistribute unmodified *
*REM Jouni Miettunen * jon@stekt.oulu.fi * Oulu * Finland * Europe * 1992 *
REM unixlike man command - manual page reader
REM Timestamp 15-Nov-1992
REM This is highly system dependent, you have to customize.
REM Note: I use FastGREP 1.72 by Christopher J. Dunford
REM Note: Only one that passed testing w/c:\man\man.man more or less correct..
break on^setlocal^unalias *^if %#==0 .or. "%1"=="-?" goto info
REM setup defaults and study what's available.
REM Note: can't use MicroEmacs or TinyView as EDITOR, has to read "file.*"
iff "%@search[fgrep]"=="" then^echo Error: need fgrep (or clone)^goto end^endiff
if "%manpath"=="" set manpath=%_cwd^set manpath=%manpath;
if "%editor"=="" set editor=list
REM Did the user give any arguments?
if "%@ascii[%1]" != "45" .or. exist %1 goto work^if %#==1 goto info
:optiot
set index=%@eval[%index+1]^set %@ascii[%@substr[%1,%index,1]]=1
if %index lt %@eval[%@len[%1]-1] goto optiot^shift
iff "%[%@ascii[k]]"=="1" then^set plaza=scan^endiff
iff "%[%@ascii[f]]"=="1" then^set plaza=names^endiff
goto %plaza
REM try to locate requested manual page
:work
path %manpath%;.^set hit=%@search[%@name[%1].*]
iff "%hit"=="" then^echo ----- Can't find manual page [%@upper[%1]]
else^%editor %hit^endiff
goto end
REM man -f ... this is how I understand -f option..
:scan
gosub polku
fgrep -fx0 "%1" %try%\*.*>&>nul
iff "%manpath"=="" .or. %manpath==; then^goto end^else^unset index^goto scan^endiff
REM man -k ... find manual pages with requested string in its name..
:names
gosub polku
iff exist %try\*%1*.* then
%try\^echo [%@upper[%_cwds]]^for %a in (*.*) echo %a|fgrep -sx "%1"|fgrep -sxv ".%1"^cd ->&nul^endiff
REM for %a in (%try\*.*) echo %a|find "%1"|find/v ".%1"
if "%manpath"=="" .or. %manpath==; goto end
unset index^goto names
REM Check all directories in %MANPATH and finally the current directory
:polku
set index=%@eval[%index+1]
iff %@substr[%manpath,%index,1] != ; .and. %index lt %@len[%manpath] then
goto polku
else^set try=%@substr[%manpath,0,%index]^set manpath=%@substr[%manpath,%@eval[%index+1]]
endiff^return
:info
echo %@lower[%@name[%0]] [-option] command
text
-f manpages with "command" in filename
-k manpages with "command" in text
-? help
Environment Variable EDITOR: your preferable text editor
Environment Variable MANPATH: where to look for manual pages
Defaults: EDITOR=LIST MANPATH=current directory
endtext
:end
break off^quit