Multiple executables in path (Was: NON-SOURCE POSTINGS CONSIDERED HARMFUL!)

Tom Christiansen tchrist at convex.COM
Mon Jan 21 19:27:17 AEST 1991


Go away, Dan.  The quotes you needed for your solution were gross and nigh
unto illegible.  If you can't follow a simple three-line piece of simple
flow-control, I'm sorry for you.  The quoting is also obvious -- go read
your shell man page about $foo interpolation in double-quoted strings.
The parens make sense if you spend 5 seconds looking at them, thinking
about lists in csh, function calls (split) and the precedence of
assignment statements.  Following the principle of least surprise, -x
is obviously from /bin/test.  My solution really is much faster on my
machine, and provably so.  Some people want to bend over backwards for
slow, convoluted solutions that you have to dick with to get just quite
right; others don't.  You do what you want, I'll do what I want, and so
will everybody else; they'll decide what's better and easier for them.

--tom

MINE:

for $file (@ARGV) {
    for $dir (split(/:/,$ENV{"PATH"})) {
	print "$path\n" if -x ($path="$dir/$file");
    } 
}

DAN'S:

  alias which 'echo `echo "$PATH" | tr : '\''\012'\'' | sed -e '\''s+$+/\!:1+'\'' -e '\''s:^:/.[.]:'\''` | sed '\''s:/../:/:g'\'''

--
"Hey, did you hear Stallman has replaced /vmunix with /vmunix.el?  Now
 he can finally have the whole O/S built-in to his editor like he
 always wanted!" --me (Tom Christiansen <tchrist at convex.com>)



More information about the Alt.sources.d mailing list