Subject: bin/4872: Added feature for 'which'
To: None <firstname.lastname@example.org>
From: None <email@example.com>
Date: 01/22/1998 12:43:58
>Synopsis: Add -a option to which, to show _all_ matches
>Responsible: bin-bug-people (Utility Bug People)
>Arrival-Date: Thu Jan 22 10:50:00 1998
>Originator: Brian Grayson
Parallel and Distributed Systems
Electrical and Computer Engineering
The University of Texas at Austin
>Release: Jan. 1998
NetBSD marvin 1.3_BETA NetBSD 1.3_BETA (MARVIN) #25: Sun Dec 28 11:54:44 CST 1997 bgrayson@marvin:/a/c3p0/home/c3p0/src/sys/arch/i386/compile/MARVIN i386
For years, I have used a modified `which' script which
lists _all_ matching executables, instead of just the
first one. This is handy when one wonders if
there are two versions of, say, gcc installed, and you
want to check which one is being used.
With the following patch, a flag of -a to `which' will tell
it to _not_ stop at the first match.
As an example, on one of our machines, we haven't cleared
out the stale dump* executables in /usr/sbin.
% which dumpfs
% which -a dumpfs
As it turns out, the second one is the more recent one,
and should be used.
Note that if a path component is duplicated, the -a flag
will print out duplicates. I don't think there's an easy
csh fix for this.
% set path = ($path /usr/bin /usr/bin)
% which -a gcc
I have found this to be a very useful feature for quite
some time, but I'm not sure if there are compatibility
reasons for not adding such functionality to `which.'
--- /usr/bin/which Tue May 6 07:46:06 1997
+++ which Thu Jan 22 12:11:40 1998
@@ -40,6 +40,11 @@
set prompt = "% "
+if ( $1 == "-a" ) then
+ set keepgoing=1
foreach arg ( $argv )
set alius = `alias $arg`
switch ( $#alius )
@@ -65,7 +71,7 @@
if ( -x $i/$arg && ! -d $i/$arg ) then
+ if ( ! $?keepgoing) break