Someone
public text v1 · immutablePATH='/bin:/usr/bin:/usr/local/bin'
set -x
_which () {
if test 1 -ne $#
then
echo 'Wrong number of arguments.' 2>&1
return 1
else
ATH="${PATH}:"
while test -n "$ATH"
do
P="${ATH%%:*}" # first element
ATH="${ATH#*:}" # rest of elements
if test -x "$P/$1"
then return 0
fi
done
return 1 # nothing found, give up
fi
}
_which sh || echo broken
_which SH && echo broken