mandb and -r/wholewords requirement
[I posted this to the newsgroup before I realized that most of the
readers were probably subscribed - my apologies to those who are seeing
this a second time.]
I have here a short hack of a wrapper for apropos which provides the
behaviour most people are used to. (note that man -k calls apropos, so
this is the only program that needs wrapping, at least AFAIK.) If
someone feels energetic enough to make a small package of this, feel
free. I just wasn't willing to wait for the mandb author to change
this, and writing the script took less time than answering all the help
mail I'd receive in its absence.
#!/bin/sh
# apropos-wrapper.sh
#
# wrapper for apropos to make it more closely resemble the old -k behaviour;
# doesn't handle long options currently
oldopts="$@"
origprog=/usr/bin/apropos.system
#origprog=echo # for debugging
set -- `getopt dhVwrm:M: $* 2>/dev/null`
opts=""; regexreq=0; wildcardreq=0
for i
do case "$i" in
-r) regexreq=1; shift;;
-w) wildcardreq=1; shift;;
-[mM]) opts="$opts $i $2"; shift; shift;;
-[^-]*) opts="$opts $i"; shift;;
--) shift; break;;
esac
done
case "$regexreq$wildcardreq" in
11) echo "Please specify one or the other of -w or -r; man $0 for details"
exit 1;;
01) opts="-w $opts";;
*) opts="-r $opts";;
esac
#echo originally \"$oldopts\", now \"$opts $*\"
$origprog $opts $*
Reply to: