home *** CD-ROM | disk | FTP | other *** search
- #!c:sksh
-
- #*************************************************************************
- # This is a "man" function which can be used to retrieve documentation
- # files stored in a MAN: directory. These files (which are often
- # included with public domain software as "readme" files) should be
- # copied to a name such as "MAN:prog.MAN". Then, "man prog" can be used
- # to retrieve the files with the $PAGER command.
- #*************************************************************************
-
- local _fspec _loc _path
-
- [ -m 'MAN:' ] ||
- echo "MAN: must be assigned to a directory containing manpages." &&
- return 1
-
- if [ "$#" -ne 1 -o "$1" = '-?' ]
- then
- echo 'Usage:' $(basename $0) 'man-entry'
- echo ' (Displays man page entries from the MAN: directory'
- echo ' or any directory in $MANPATH)'
- return 1
- fi
-
- _fspec=''
-
- _path="${MANPATH:-MAN:,MAN:SKsh}"
-
- while [ -n "$_path" -a -z "$_fspec" ]
- do
- _loc=$(tackon $(car "$_path" ',') "$1")
- _path=$(cdr "$_path" ',')
- [ -f "$_loc.MAN" ] && _fspec="$_loc.MAN"
- [ -z "$_fspec" -a -f "$_loc.doc" ] && _fspec="$_loc.doc"
- [ -z "$_fspec" -a -f "$_loc.txt" ] && _fspec="$_loc.txt"
- done
-
- [ -z "$_fspec" ] && echo "No manual entry for $1" && return 1
-
- ${PAGER:-more} "$_fspec"
-