Multiple executables in path (Was: NON-SOURCE POSTINGS CONSIDERED HARMFUL!)
Rich Kaul
kaul at icarus.eng.ohio-state.edu
Tue Jan 22 13:24:10 AEST 1991
In article <1991Jan21.171227.12138 at convex.com> tchrist at 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 at icarus.eng.ohio-state.edu | of heaven; unfortunately, the same key
or ...!osu-cis!kaul | opens the door to hell.
More information about the Alt.sources.d
mailing list