Multiple executables in path (Was: NON-SOURCE POSTINGS CONSIDERED HARMFUL!)
Dan Bernstein
brnstnd at kramden.acf.nyu.edu
Thu Jan 24 00:09:43 AEST 1991
In article <8807 at star.cs.vu.nl> maart at cs.vu.nl (Maarten Litmaath) writes:
> In article <17373:Jan1908:30:3191 at kramden.acf.nyu.edu>,
> brnstnd at kramden.acf.nyu.edu (Dan Bernstein) writes:
> )Hmmm. I've always been satisfied with the speed of
> [_Excessively_ long line split.]
> ) alias which 'echo `echo "$PATH" | tr : '\''\012'\'\
> ) ' | sed -e '\''s+$+/\!:1+'\'' -e '\''s:^:/.[.]:'\'\
> ) '` | sed '\''s:/../:/:g'\'''
> This alias doesn't deal with aliases (easily fixed), but most importantly
> it _fails_.
No, it does exactly what it's meant to do.
> % which passwd
> /bin/passwd /usr/bin/passwd /etc/passwd
> # How odd: /etc/passwd is executable!
I like a which that points out non-executables in PATH, because it shows
quite clearly any wasted exec()s.
> % set path=($path .)
> % cp /bin/true foo
> % which foo
> # Silence.
It is a mistake to have . (or any other relative directories, if your
system supports them) in your path.
> Had you read the documentation of `which5', you would have known it's not
> that trivial to get things right.
Different people will prefer different behaviors of ``which''; no single
behavior is right. (Should we say that which5 is wrong because it
doesn't follow the BSD which man page?)
---Dan
More information about the Alt.sources.d
mailing list