summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin
diff options
context:
space:
mode:
authorwosch <wosch@FreeBSD.org>1996-09-14 23:20:33 +0000
committerwosch <wosch@FreeBSD.org>1996-09-14 23:20:33 +0000
commite394564f7626f999f6512750b8ce79d526b01085 (patch)
tree41e3e969dd5fb2981b32ded58acf447d8d37eb14 /gnu/usr.bin
parentd403258fea7691c67c39410c61382b35c6c89d75 (diff)
downloadFreeBSD-src-e394564f7626f999f6512750b8ce79d526b01085.zip
FreeBSD-src-e394564f7626f999f6512750b8ce79d526b01085.tar.gz
Cleanup exit status; 2: syntax error, 0: keyword matched,
$exit_nomatch: no keyword matched. Default value for variable exit_nomatch is 0 because `man -k' don't like exit status != 0 Detected by: "Stephen J. Roznowski" <sjr@zombie.ncsc.mil>
Diffstat (limited to 'gnu/usr.bin')
-rw-r--r--gnu/usr.bin/man/apropos/apropos.sh19
1 files changed, 12 insertions, 7 deletions
diff --git a/gnu/usr.bin/man/apropos/apropos.sh b/gnu/usr.bin/man/apropos/apropos.sh
index e14fbbe..1545dec 100644
--- a/gnu/usr.bin/man/apropos/apropos.sh
+++ b/gnu/usr.bin/man/apropos/apropos.sh
@@ -15,17 +15,21 @@
# The University of Texas at Austin
# Austin, Texas 78712
#
-# $Id: apropos.sh,v 1.4 1996/07/08 20:03:18 wosch Exp $
+# $Id: apropos.sh,v 1.5 1996/08/27 20:03:55 wosch Exp $
PATH=/bin:/usr/bin:$PATH
db=whatis # name of whatis data base
grepopt=''
+# man -k complain if exit_nomatch=1 and no keyword matched
+: ${exit_nomatch=0}
+exit_error=2
+
# argument test
case $# in 0)
echo "usage: `basename $0` keyword ..." >&2
- exit 1
+ exit $exit_error
;;
esac
@@ -61,7 +65,7 @@ done
case X"$mandir" in X)
echo "`basename $0`: no whatis databases in $manpath" >&2
- exit 1
+ exit $exit_error
esac
@@ -77,17 +81,18 @@ done |
while read line
do
case $line in
+ # collect error(s)
*": nothing appropriate") line2="$line2$line\n";;
+ # matched line or EOF
*) break;;
esac
done
# nothing found, exit
if test -z "$line" -a ! -z "$line2"; then
- case X"$line2" in X);; *) printf "$line2";; esac
- exit 1
+ printf "$line2"
+ exit $exit_nomatch
else
- ( case X"$line2" in X);; *) printf "$line2";; esac
- echo $line; cat ) | $PAGER
+ ( printf "$line2"; echo $line; cat ) | $PAGER
fi
)
OpenPOWER on IntegriCloud