Path: utzoo!utgpu!cs.utexas.edu!yale!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: alt.sources.d Subject: Re: Multiple executables in path (Was: NON-SOURCE POSTINGS CONSIDERED HARMFUL!) Message-ID: <9688:Jan2313:09:4391@kramden.acf.nyu.edu> Date: 23 Jan 91 13:09:43 GMT References: <17373:Jan1908:30:3191@kramden.acf.nyu.edu> <8807@star.cs.vu.nl> Organization: IR Lines: 36 In article <8807@star.cs.vu.nl> maart@cs.vu.nl (Maarten Litmaath) writes: > In article <17373:Jan1908:30:3191@kramden.acf.nyu.edu>, > brnstnd@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