Subject: Re: bin/13462: which(1) should not be implemented in csh(1)
To: Akinori MUSHA <knu@iDaemons.org>
From: Greg A. Woods <woods@weird.com>
List: netbsd-bugs
Date: 07/14/2001 14:20:29
[ On Saturday, July 14, 2001 at 22:49:34 (+0900), Akinori MUSHA wrote: ]
> Subject: bin/13462: which(1) should not be implemented in csh(1)
>
> >Fix:
>
> Reimplement which(1) in C or bourne shell. FreeBSD 5-CURRENT
> has a C version, which you might want to import. Needless to
> say, it's easy to implement one from scratch.
You mean like this? :-) [[been there, done that, long ago! I have no
csh today!]]
#! /bin/sh
:
if [ "$1" = "-a" ] ; then
#
# We could search the PATH explicitly by individually setting
# PATH to each of its components and then trying "type"....
#
echo "$(basename $0): -a not supported in this version" 1>&2
exit 2
fi
# XXX this isn't a very true emulation since we explicitly ignore
# aliases and functions...
#
for prog
do
# NOTE: If this were a ksh script then it could just call "command -v"
location=$(expr "$(type ${prog})" : '[^/]*\(.*\)$')
if [ -n "${location}" ] ; then
echo "${location}"
fi
done
exit 0
--
Greg A. Woods
+1 416 218-0098 VE3TCP <gwoods@acm.org> <woods@robohack.ca>
Planix, Inc. <woods@planix.com>; Secrets of the Weird <woods@weird.com>