No. It relies on $PATH being set to include whatever directory perl is
in, which is even more probable.
> If perl isn't in /usr/bin it is unlikely to
>be in root's path
Not true. perl being so widely used, chances are it's in the path of
whichever account is used to compile software, including the kernel
(not root on my box). /usr/bin is the most likely location of perl,
true, and it's also very likely to be in $PATH. Most importantly,
these two phenomena have a common cause -- the directory containing
perl is very likely to be in $PATH.
> Checking /usr/bin is a better choice,
>since it will find it on all Linux (FSSTND-compliant) systems.
And checking $PATH will find it on almost all the above, plus a lot of
non-FSSTND-compliant systems. Check $PATH and then /usr/bin as well,
if you feel that's necessary.
Best of all, *don't* check for perl in any directories -- just do
`(perl -e '') 2>/dev/null`, and if it succeeds then you have perl
available in the path. Add /usr/bin to $PATH first if you really want
to.
if (perl -e '') 2>/dev/null; then
perl wherever/the/perl/script/is
else
awk wherever/the/awk/script/is
fi
Much better than all this pointless messing around looking for
executables in hard-coded directories, no?
I'm continually amazed by installation scripts that try to do something
in a clever and complicated way that doesn't work, when the simplest
possible way would work almost anywhere. The kernel Makefile, which
tries to locate bash in order to run the config script, is an excellent
example -- it looks at $BASH, and then tries /bin/bash, and then as a
fallback runs sh from the path. Sure, this works on most Linux
systems, but it doesn't work on mine, where sh is ash and bash is in
/usr/gnu/bin. If it had just tried running bash from the path, it
would either have found it because /usr/gnu/bin was in the path, or it
would fail in an obvious and meaningful way that I can easily fix.
(The fact that the script starts with "#!/bin/sh" doesn't help, nor
does the fact that its test to see if it's running under bash isn't
reliable, but they are comparatively minor issues.)
-zefram