Path: utzoo!utgpu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!sample.eng.ohio-state.edu!icarus!kaul From: kaul@icarus.eng.ohio-state.edu (Rich Kaul) Newsgroups: alt.sources.d Subject: Re: Multiple executables in path (Was: NON-SOURCE POSTINGS CONSIDERED HARMFUL!) Message-ID: Date: 22 Jan 91 02:24:10 GMT References: <26327:Jan2023:24:4091@kramden.acf.nyu.edu> <1991Jan21.082717.22130@convex.com> <305:Jan2114:26:5191@kramden.acf.nyu.edu> <1991Jan21.171227.12138@convex.com> Sender: kaul@ee.eng.ohio-state.edu (Rich Kaul) Organization: The Ohio State University Dept of Electrical Engineering Lines: 27 In-Reply-To: tchrist@convex.COM's message of 21 Jan 91 17:12:27 GMT In article <1991Jan21.171227.12138@convex.com> tchrist@convex.COM (Tom Christiansen) writes: Here's my solution: $file = shift; for $dir (split(/:/,$ENV{"PATH"})) { print "$path\n" if -x ($path="$dir/$file"); } [ ... ] I'd like to see others' opinions on algorithmic complexity here. Which way is more straightforward? After seeing Dan's solution, either the perl code or the ksh script are far simpler to maintain for most users. I would hate to give that alias to some naive user. The first time he looked at his list of aliases and wanted an explaination of what that alias did would take a lot of educating in slightly more obsure things than most users need to know -- and it's more time that I have to spend on such things. Besides, I have a soft spot for perl ;-) Also, I should mention that none of the the above solutions work well with bash, where you can have a PATH with unexpanded ~ references in the PATH environment variable. There are other tricks you have to play on that shell to get these scripts to work. -- Rich Kaul | Every man is given the key to the door kaul@icarus.eng.ohio-state.edu | of heaven; unfortunately, the same key or ...!osu-cis!kaul | opens the door to hell.