home *** CD-ROM | disk | FTP | other *** search
/ BUG 1 / BUGCD1996_0708.ISO / pc / util / minilin / minilin.exe / USR / BIN / WHATIS < prev    next >
Text File  |  1994-05-29  |  1KB  |  70 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. # whatis-1.3 aeb 940331
  19. #
  20.  
  21. PATH=/usr/local/bin:/bin:/usr/ucb:/usr/bin
  22.  
  23. libdir=/usr/lib
  24.  
  25. if [ $# = 0 ]
  26. then
  27.     echo "usage: `basename $0` name ..."
  28.     exit 1
  29. fi
  30.  
  31. manpath=`/usr/bin/man --path | tr : '\040'`
  32.  
  33. if [ "$manpath" = "" ]
  34. then
  35.     echo "whatis: manpath is null"
  36.     exit 1
  37. fi
  38.  
  39. if [ "$PAGER" = "" ]
  40. then
  41.     PAGER="/usr/bin/less -s"
  42. fi
  43.  
  44. while [ $1 ]
  45. do
  46.     found=0
  47.     for d in $manpath /usr/lib
  48.     do
  49.         if [ -f $d/whatis ]
  50.         then
  51.             grep -iw "^$1" $d/whatis
  52.             status=$?
  53.             if [ "$status" = "0" ]
  54.             then
  55.                 found=1
  56.         export found
  57.             fi
  58.         fi
  59.     done
  60.  
  61.     if [ "$found" = "0" ]
  62.     then
  63.         echo "$1: nothing appropriate"
  64.     fi
  65.  
  66.     shift
  67. done | $PAGER
  68.  
  69. exit
  70.