home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / man11a.zip / apropos.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1994-01-23  |  1KB  |  65 lines

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