home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / OS2 / MAN11A.ZIP / src / whatis.sh < prev   
Linux/UNIX/POSIX Shell Script  |  1991-08-25  |  1KB  |  67 lines

  1. #!/bin/sh
  2. #
  3. # whatis -- search the whatis database for keywords.  Like apropos,
  4. #           but match only commands (as whole words).
  5. #
  6. # Copyright (c) 1990, 1991, John W. Eaton.
  7. #
  8. # You may distribute under the terms of the GNU General Public
  9. # License as specified in the README file that comes with the man
  10. # distribution.  
  11. #
  12. # John W. Eaton
  13. # jwe@che.utexas.edu
  14. # Department of Chemical Engineering
  15. # The University of Texas at Austin
  16. # Austin, Texas  78712
  17.  
  18. PATH=/usr/local/bin:/bin:/usr/ucb:/usr/bin
  19.  
  20. libdir=%libdir%
  21.  
  22. if [ $# = 0 ]
  23. then
  24.     echo "usage: `basename $0` name ..."
  25.     exit 1
  26. fi
  27.  
  28. manpath=`%bindir%/manpath -q | tr : '\040'`
  29.  
  30. if [ "$manpath" = "" ]
  31. then
  32.     echo "whatis: manpath is null"
  33.     exit 1
  34. fi
  35.  
  36. if [ "$PAGER" = "" ]
  37. then
  38.     PAGER="%pager%"
  39. fi
  40.  
  41. while [ $1 ]
  42. do
  43.     found=0
  44.     for d in $manpath /usr/lib
  45.     do
  46.         if [ -f $d/whatis ]
  47.         then
  48.             grep -iw "^$1" $d/whatis
  49.             status=$?
  50.             if [ "$status" = "0" ]
  51.             then
  52.                 found=1
  53.                 export found;
  54.             fi
  55.         fi
  56.     done
  57.  
  58.     if [ "$found" = "0" ]
  59.     then
  60.         echo "$1: nothing appropriate"
  61.     fi
  62.  
  63.     shift
  64. done | $PAGER
  65.  
  66. exit
  67.