3
# Copyright 1999-2005 The Apache Software Foundation or its licensors, as
6
# Licensed under the Apache License, Version 2.0 (the "License");
7
# you may not use this file except in compliance with the License.
8
# You may obtain a copy of the License at
10
# http://www.apache.org/licenses/LICENSE-2.0
12
# Unless required by applicable law or agreed to in writing, software
13
# distributed under the License is distributed on an "AS IS" BASIS,
14
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
# See the License for the specific language governing permissions and
16
# limitations under the License.
19
# Look for program[s] somewhere in $PATH.
23
# Do not print out full pathname. (silent)
25
# Look in PATHNAME instead of $PATH
28
# PrintPath [-s] [-pPATHNAME] program [program ...]
30
# Initially written by Jim Jagielski for the Apache configuration mechanism
31
# (with kudos to Kernighan/Pike)
40
# Find out what OS we are running for later on
42
os=`(uname) 2>/dev/null`
51
-p* ) pathname="`echo $args | sed 's/^..//'`" ;;
52
* ) programs="$programs $args" ;;
57
# Now we make the adjustments required for OS/2 and everyone
60
# First of all, all OS/2 programs have the '.exe' extension.
61
# Next, we adjust PATH (or what was given to us as PATH) to
62
# be whitespace separated directories.
63
# Finally, we try to determine the best flag to use for
64
# test/[] to look for an executable file. OS/2 just has '-r'
65
# but with other OSs, we do some funny stuff to check to see
66
# if test/[] knows about -x, which is the prefered flag.
69
if [ "x$os" = "xOS/2" ]
72
pathname=`echo -E $pathname |
80
ext="" # No default extensions
81
pathname=`echo $pathname |
86
# Here is how we test to see if test/[] can handle -x
89
cat > $testfile <<ENDTEST
91
if [ -x / ] || [ -x /bin ] || [ -x /bin/ls ]; then
97
if `/bin/sh $testfile 2>/dev/null`; then
105
for program in $programs
107
for path in $pathname
109
if [ $test_exec_flag $path/${program}${ext} ] && \
110
[ ! -d $path/${program}${ext} ]; then
111
if [ "x$echo" = "xyes" ]; then
112
echo $path/${program}${ext}
117
# Next try without extension (if one was used above)
118
if [ "x$ext" != "x" ]; then
119
if [ $test_exec_flag $path/${program} ] && \
120
[ ! -d $path/${program} ]; then
121
if [ "x$echo" = "xyes" ]; then
122
echo $path/${program}