diff options
author | wkj <devnull@localhost> | 2004-04-21 03:20:56 +0000 |
---|---|---|
committer | wkj <devnull@localhost> | 2004-04-21 03:20:56 +0000 |
commit | 6d7a57dea4e27ace711c44d844d4418fe786160d (patch) | |
tree | ea28989b9f7acb399a57bf27e01d2cc4808db3e2 | |
parent | 146cf9377d5af7ec9d49d54b861fc62d5fe04aac (diff) | |
download | plan9port-6d7a57dea4e27ace711c44d844d4418fe786160d.tar.gz plan9port-6d7a57dea4e27ace711c44d844d4418fe786160d.tar.bz2 plan9port-6d7a57dea4e27ace711c44d844d4418fe786160d.zip |
Import man9 shell script for reading Plan 9 man pages with Unix nroff.
Seems to mostly work under FreeBSD; needs some testing under Linux.
-rwxr-xr-x | bin/man9 | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/bin/man9 b/bin/man9 new file mode 100755 index 00000000..4eebf7cb --- /dev/null +++ b/bin/man9 @@ -0,0 +1,43 @@ +#! /bin/sh +root=$PLAN9/man + +while [ $# -gt 0 ] ; do + case $1 in + [0-9]) sec="$sec $1" ;; + *) break ;; + esac + shift +done + +if [ "X$sec" = "X" ] ; then + sec=`ls -d $root/[0-9]* | sed -e 's;/$;;' -e 's;^.*/;;'` +fi + +pat='^('`echo $* | sed -e 's; ;|;g'`')' ; +for s in $sec ; do + if [ -f $root/$s/INDEX ] ; then + try=`grep -E $pat $root/$s/INDEX | sed -e 's;^[^ ]* ;;'` ; + fi + if [ "X$try" != "X" ] ; then + for f in $try ; do + files="$files $root/$s/$f"; + done + try=""; + fi + for f in $* ; do + if [ -f $root/$s/$f ] ; then + files="$files $root/$s/$f" ; + fi + done +done + +files=`echo $files | tr ' ' '\n' | sort -u`; + +if [ "X$files" = "X" ] ; then + echo "No manual entry for $*"; + exit 1; +fi + +exmac=".de EX\n.ift .ft 5\n.nf\n..\n.de EE\n.ft1\n.fi\n.." +( echo -e $exmac ; cat $files ) | nroff -man + |