Path: utzoo!utgpu!cs.utexas.edu!convex!news From: tchrist@convex.COM (Tom Christiansen) Newsgroups: alt.sources.d Subject: Re: Multiple executables in path (Was: NON-SOURCE POSTINGS CONSIDERED HARMFUL!) Message-ID: <1991Jan19.105624.15369@convex.com> Date: 19 Jan 91 10:56:24 GMT References: <1991Jan17.224403.16050@convex.com> <17373:Jan1908:30:3191@kramden.acf.nyu.edu> Sender: news@convex.com (news access account) Reply-To: tchrist@convex.COM (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 31 Nntp-Posting-Host: pixel.convex.com From the keyboard of brnstnd@kramden.acf.nyu.edu (Dan Bernstein): :Hmmm. I've always been satisfied with the speed of : : alias which 'echo `echo "$PATH" | tr : '\''\012'\'' | sed -e '\''s+$+/\!:1+'\'' -e '\''s:^:/.[.]:'\''` | sed '\''s:/../:/:g'\''' But it doesn't do the same thing as mine does, Dan. Yours is more like this: for $file (@ARGV) { for $dir (split(/:/,$ENV{'PATH'})) { print $path,"\n" if -x ($path="$dir/$file"); } } except that it uses many more processes, runs more slowly, and is significantly more difficult to read and thus maintain. But as I said, the original code does something different: it doesn't just tell you which paths lead to a particular command. Rather, it produces a complete list of all commands in your $PATH with more than one path to them, except for those duplicates that are just there due to symlinks to the same executable and by the same name, such as /etc/foo -> /usr/etc/foo. That's why the $files{$name, $dev, $ino} array is kept. I doubt you can do the last part with a csh alias, and even if you could, I wouldn't want to try to make sense out of it, unless of course it just pointed to my script. :-) --tom -- "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 )