#!/bin/sh # # ${MANDB} is filled with a result of: # # find /usr/src -name "*.[0-9]" > ${MANDB} # MANDB=~/bin/man.db # # Wrong usage or potential tries to see manual page that does not exist finish # with calling man(1) by hand to get smart comment. # if [ $# -eq 0 ]; then man fi error=`man ${@} 2>&1` if [ $? -ne 0 ]; then echo "${error}" exit 1; fi _sec="" _pg="" _path="" _lookdir=`echo ${MANPATH} | sed 's/:/ /g'` viewman() { # # ${MANSRC} is about saying less(1) which file will be opened # once some key combination defined by lesskey(1) will be pressed. # export MANSRC="${_path}" groff -Tascii -man "${_path}" | less } if [ $# -eq 2 ]; then _sec=$1 _pg=$2 _path=/usr/src/share/man/man${_sec}/${_pg}.${_sec} echo "# Viewing ${_path}" viewman; else _pg=$1 egrep ".*\/${_pg}.[0-9]$" ${MANDB} | while read _f; do _path=${_f} viewman; exit 0; done fi