2
# Look for program[s] somewhere in $PATH.
6
# Do not print out full pathname. (silent)
8
# Look in PATHNAME instead of $PATH
11
# PrintPath [-s] [-pPATHNAME] program [program ...]
13
# Initially written by Jim Jagielski for the Apache configuration mechanism
14
# (with kudos to Kernighan/Pike)
16
# This script falls under the Apache License.
17
# See http://www.apache.org/licenses/LICENSE
26
# Find out what OS we are running for later on
28
os=`(uname) 2>/dev/null`
37
-p* ) pathname="`echo $args | sed 's/^..//'`" ;;
38
* ) programs="$programs $args" ;;
43
# Now we make the adjustments required for OS/2 and everyone
46
# First of all, all OS/2 programs have the '.exe' extension.
47
# Next, we adjust PATH (or what was given to us as PATH) to
48
# be whitespace seperated directories.
49
# Finally, we try to determine the best flag to use for
50
# test/[] to look for an executable file. OS/2 just has '-r'
51
# but with other OSs, we do some funny stuff to check to see
52
# if test/[] knows about -x, which is the prefered flag.
55
if [ "x$os" = "xOS/2" ]
58
pathname=`echo -E $pathname |
66
ext="" # No default extensions
67
pathname=`echo $pathname |
72
# Here is how we test to see if test/[] can handle -x
75
cat > $testfile <<ENDTEST
77
if [ -x / ] || [ -x /bin ] || [ -x /bin/ls ]; then
83
if `/bin/sh $testfile 2>/dev/null`; then
91
for program in $programs
95
if [ $test_exec_flag $path/${program}${ext} ] && \
96
[ ! -d $path/${program}${ext} ]; then
97
if [ "x$echo" = "xyes" ]; then
98
echo $path/${program}${ext}
103
# Next try without extension (if one was used above)
104
if [ "x$ext" != "x" ]; then
105
if [ $test_exec_flag $path/${program} ] && \
106
[ ! -d $path/${program} ]; then
107
if [ "x$echo" = "xyes" ]; then
108
echo $path/${program}