home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / unix / armlinux / alpha / PARTITIONS / USR_GZ / usr / bin / apropos < prev    next >
Encoding:
Text File  |  1995-06-08  |  1.6 KB  |  102 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. # apropos-1.4 aeb 941007
  18. #
  19.  
  20. PATH=/usr/local/bin:/bin:/usr/ucb:/usr/bin
  21.  
  22. libdir=/usr/lib
  23.  
  24. if [ $# = 0 ]
  25. then
  26.     echo "usage: `basename $0` keyword ..."
  27.     exit 1
  28. fi
  29.  
  30. manpath=`/usr/bin/man --path | tr : '\040'`
  31.  
  32. if [ "$manpath" = "" ]
  33. then
  34.     echo "apropos: manpath is null"
  35.     exit 1
  36. fi
  37.  
  38. if [ "$PAGER" = "" ]
  39. then
  40.     PAGER="/usr/bin/less -s"
  41. fi
  42.  
  43. # avoid using a pager if only output is "nothing appropriate"
  44. nothing=
  45. found=0
  46. while [ $found = 0 -a -n "$1" ]
  47. do
  48.     for d in $manpath /usr/lib
  49.     do
  50.         if [ -f $d/whatis ]
  51.         then
  52.             if grep -is "^$1" $d/whatis
  53.             then
  54.                 found=1
  55.             fi
  56.         fi
  57.     done
  58.     if [ $found = 0 ]
  59.     then
  60.     nothing="$nothing $1"
  61.     shift
  62.     fi
  63. done
  64.  
  65. if [ $found = 0 ]
  66. then
  67.     for i in $nothing
  68.     do
  69.     echo "$i: nothing appropriate"
  70.     done
  71.     exit
  72. fi
  73.  
  74. while [ $1 ]
  75. do
  76.     for i in $nothing
  77.     do
  78.     echo "$i: nothing appropriate"
  79.     done
  80.     nothing=
  81.     found=0
  82.     for d in $manpath /usr/lib
  83.     do
  84.         if [ -f $d/whatis ]
  85.         then
  86.             if grep -i "^$1" $d/whatis
  87.             then
  88.                 found=1
  89.             fi
  90.         fi
  91.     done
  92.  
  93.     if [ $found = 0 ]
  94.     then
  95.         echo "$1: nothing appropriate"
  96.     fi
  97.  
  98.     shift
  99. done | $PAGER
  100.  
  101. exit
  102.