Subject: Re: bin/10611: /usr/bin/which reads user's .chsrc even if user's shell is not csh
To: None <netbsd-bugs@netbsd.org>
From: Greg A. Woods <woods@weird.com>
List: netbsd-bugs
Date: 07/20/2000 12:03:54
[ On Wednesday, July 19, 2000 at 18:51:42 (+1000), Robert Elz wrote: ]
> Subject: Re: bin/10611: /usr/bin/which reads user's .chsrc even if user's shell is not csh 
>
> Today, the best solution is probably
> 	rm -fr /usr/src/bin/csh /usr/src/usr.bin/which /usr/pkgsrc/shells/tcsh

I couldn't agree more!  (remember http://www.perl.com/pub/language/versus/csh.html)

However as a *former* (LONG former!) csh user I still find my finger
memory sometimes types "which" before I think to type "type", so since I
have done the above already on my development systems I've replaced
/usr/bin/which with this quick little hack:

	#! /bin/sh
	:
	
	if [ "$1" = "-a" ] ; then
	        echo "$(basename $0): -a not supported in this version" 1>&2
	        exit 2
	fi
	for prog
	do
	        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>      <robohack!woods>
Planix, Inc. <woods@planix.com>; Secrets of the Weird <woods@weird.com>