mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-20 11:11:24 +00:00
share the code between apropos and whatis
This commit is contained in:
parent
83bf11d386
commit
d31934acb9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=14460
@ -1,6 +1,9 @@
|
||||
# $Id: Makefile,v 1.9 1995/07/25 00:33:07 bde Exp $
|
||||
# $Id: Makefile,v 1.1 1996/03/09 17:31:08 wosch Exp wosch $
|
||||
|
||||
SHPROG= apropos
|
||||
|
||||
MLINKS= apropos.1 whatis.1
|
||||
LINKS= ${BINDIR}/apropos ${BINDIR}/whatis
|
||||
|
||||
.include "../../Makefile.inc"
|
||||
.include "../Makefile.shprog"
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" Man page for apropos
|
||||
.\" Man page for apropos an whatis
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1991, John W. Eaton.
|
||||
.\"
|
||||
@ -15,13 +15,19 @@
|
||||
.TH apropos 1 "Jan 15, 1991"
|
||||
.LO 1
|
||||
.SH NAME
|
||||
apropos \- search the whatis database for strings
|
||||
apropos, whatis \- search the whatis database
|
||||
.SH SYNOPSIS
|
||||
.BI apropos
|
||||
keyword ...
|
||||
|
||||
.BI whatis
|
||||
keyword ...
|
||||
.SH DESCRIPTION
|
||||
apropos searches a set of database files containing short descriptions
|
||||
.B apropos
|
||||
searches a set of database files containing short descriptions
|
||||
of system commands for keywords and displays the result on the
|
||||
standard output.
|
||||
.B whatis
|
||||
display only complete word matches.
|
||||
.SH "SEE ALSO"
|
||||
whatis(1), man(1).
|
||||
man(1), makewhatis(1).
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
PATH=/bin:/usr/bin:$PATH
|
||||
db=whatis # name of whatis data base
|
||||
grepopt=''
|
||||
|
||||
# argument test
|
||||
case $# in 0)
|
||||
@ -29,6 +30,11 @@ case $# in 0)
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$0" in
|
||||
*whatis) grepopt='-w';; # run as whatis(1)
|
||||
*) grepopt='';; # otherwise run as apropos(1)
|
||||
esac
|
||||
|
||||
# test manpath
|
||||
manpath=`%bindir%/manpath -q | tr : '\040'`
|
||||
case X"$manpath" in X)
|
||||
@ -62,7 +68,7 @@ esac
|
||||
|
||||
for manpage
|
||||
do
|
||||
if grep -hi "$manpage" $mandir; then :
|
||||
if grep -hi $grepopt "$manpage" $mandir; then :
|
||||
else
|
||||
echo "$manpage: nothing appropriate"
|
||||
fi
|
||||
|
@ -1,6 +0,0 @@
|
||||
# $Id$
|
||||
|
||||
SHPROG= whatis
|
||||
|
||||
.include "../../Makefile.inc"
|
||||
.include "../Makefile.shprog"
|
@ -1,27 +0,0 @@
|
||||
.\" Man page for whatis
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1991, John W. Eaton.
|
||||
.\"
|
||||
.\" You may distribute under the terms of the GNU General Public
|
||||
.\" License as specified in the README file that comes with the man 1.0
|
||||
.\" distribution.
|
||||
.\"
|
||||
.\" John W. Eaton
|
||||
.\" jwe@che.utexas.edu
|
||||
.\" Department of Chemical Engineering
|
||||
.\" The University of Texas at Austin
|
||||
.\" Austin, Texas 78712
|
||||
.\"
|
||||
.TH whatis 1 "Jan 5, 1991"
|
||||
.LO 1
|
||||
.SH NAME
|
||||
whatis \- search the whatis database for complete words.
|
||||
.SH SYNOPSIS
|
||||
.BI whatis
|
||||
keyword ...
|
||||
.SH DESCRIPTION
|
||||
whatis searches a set of database files containing short descriptions
|
||||
of system commands for keywords and displays the result on the
|
||||
standard output. Only complete word matches are displayed.
|
||||
.SH "SEE ALSO"
|
||||
apropos(1), man(1).
|
@ -1,66 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# whatis -- search the whatis database for keywords. Like apropos,
|
||||
# but match only commands (as whole words).
|
||||
#
|
||||
# Copyright (c) 1990, 1991, John W. Eaton.
|
||||
#
|
||||
# You may distribute under the terms of the GNU General Public
|
||||
# License as specified in the README file that comes with the man
|
||||
# distribution.
|
||||
#
|
||||
# John W. Eaton
|
||||
# jwe@che.utexas.edu
|
||||
# Department of Chemical Engineering
|
||||
# The University of Texas at Austin
|
||||
# Austin, Texas 78712
|
||||
|
||||
PATH=/usr/local/bin:/bin:/usr/ucb:/usr/bin
|
||||
|
||||
libdir=%libdir%
|
||||
|
||||
if [ $# = 0 ]
|
||||
then
|
||||
echo "usage: `basename $0` name ..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
manpath=`%bindir%/manpath -q | tr : '\040'`
|
||||
|
||||
if [ "$manpath" = "" ]
|
||||
then
|
||||
echo "whatis: manpath is null"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$PAGER" = "" ]
|
||||
then
|
||||
PAGER="%pager%"
|
||||
fi
|
||||
|
||||
while [ $1 ]
|
||||
do
|
||||
found=0
|
||||
for d in $manpath /usr/lib
|
||||
do
|
||||
if [ -f $d/whatis ]
|
||||
then
|
||||
grep -iw "^$1" $d/whatis
|
||||
status=$?
|
||||
if [ "$status" = "0" ]
|
||||
then
|
||||
found=1
|
||||
export found;
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$found" = "0" ]
|
||||
then
|
||||
echo "$1: nothing appropriate"
|
||||
fi
|
||||
|
||||
shift
|
||||
done | $PAGER
|
||||
|
||||
exit
|
Loading…
Reference in New Issue
Block a user