Exits 0 on success, and 1 if no keyword matched.

Start $PAGER only if we find a manual page.
This commit is contained in:
Wolfram Schneider 1996-07-08 20:03:18 +00:00
parent b184bc75f3
commit bfab15f069
2 changed files with 24 additions and 3 deletions

View File

@ -28,6 +28,9 @@ 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.
display only complete word matches.
The
.B apropos
utility exits 0 on success, and 1 if no keyword matched.
.SH "SEE ALSO"
man(1), makewhatis(1).

View File

@ -16,7 +16,7 @@
#
# rewritten by Wolfram Schneider, Berlin, Feb 1996
#
# $Id: $
# $Id: apropos.sh,v 1.3 1996/03/10 18:52:09 wosch Exp $
PATH=/bin:/usr/bin:$PATH
@ -72,5 +72,23 @@ do
else
echo "$manpage: nothing appropriate"
fi
done | $PAGER
done |
( # start $PAGER only if we find a manual page
while read line
do
case $line in
*": nothing appropriate") line2="$line2$line\n";;
*) break;;
esac
done
# nothing found, exit
if test -z "$line" -a ! -z "$line2"; then
case X"$line2" in X);; *) printf "$line2";; esac
exit 1
else
( case X"$line2" in X);; *) printf "$line2";; esac
echo $line; cat ) | $PAGER
fi
)