Subject: Re: bin/10611: /usr/bin/which reads user's .chsrc even if user's shell is not csh
To: Robert Elz <kre@munnari.OZ.AU>
From: Todd Whitesel <toddpw@best.com>
List: netbsd-bugs
Date: 07/19/2000 02:39:42
>It isn't arguably wrong, or just done for hysterical reasons - it is
>essential to the correct operation of which.   The purpose of "which"
>is to allow csh users to find out what will happen if they type some
>command.  For that to work, it has to be able to find the user's aliases,
>path setting, etc, and while it isn't perfect (it doesn't find anything altered
>in the current shell) sourcing the user's cshrc is the way that is done.

IMHO not finding anything altered in the current shell is "arguably wrong".

That is the main thing I use which(1) for, and while I (ages ago) renovated
my .cshrc to imitate .profile/.env, I find that the tcsh built-in "which"
is a far better solution. All my important accounts have a tcsh installed.

You do have a point that it was not done for purely hysterical reasons.
A revised diff appears below.

As for flamage, if you don't care to hear the flames then it is better to
refrain from posting your lighter fluid in the first place.

Todd Whitesel
toddpw @ best.com

Index: which.1
===================================================================
RCS file: /cvsroot/basesrc/usr.bin/which/which.1,v
retrieving revision 1.6
diff -u -r1.6 which.1
--- which.1	1999/03/22 18:16:47	1.6
+++ which.1	2000/07/19 09:32:34
@@ -75,9 +75,30 @@
 word,
 or if an executable file with the argument name was not found in the path.
 .Sh BUGS
-Must be executed by a
-.Xr csh 1 ,
-or some other shell which knows about aliases.
+.Nm
+always sources the user's
+.Pa \&.cshrc
+file if it exists.
+This is required for aliases to be processed correctly, but it will have
+undesirable consequences if
+.Pa \&.cshrc
+unconditionally changes the
+.Ev PATH
+variable.
+Users of shells other than
+.Xr csh 1
+should avoid
+.Nm
+in favor of their chosen shell's equivalent command.
+For example,
+.Xr sh 1
+provides
+.Ic type ,
+and
+.Xr ksh 1
+additionally provides
+.Ic whence ,
+for this purpose.
 .Sh HISTORY
 The
 .Nm