Path Program
michael.p.lindner
mpl at cbnewsl.ATT.COM
Wed Jun 21 01:08:56 AEST 1989
In article <720 at censor.UUCP>, markk at censor.UUCP (Mark Keating) writes:
>
> I also recieved a script, and one was posted as well to do the
> same thing with the exception that path entries located are
> not conditionally passed through `ls', which I find very useful
>
> The thing I liked about the one script was to specify the path, BUT since
> everything that is an option, is blindly passed to ls for simplicity,
> anybody have a good suggestion on the best way to handle this ??
simple! Here's the revised script:
options=
while [ "$#" -gt 0 ]
do
case "$1" in
--)
shift
break
;;
-*)
options="$options $1"
shift
;;
*)
break
;;
esac
done
IFS=":$IFS"
case "$#" in
0)
echo >&2 "usage: $0 file [path ... ]"
exit 1
;;
1)
file="$1"
shift
for d in $PATH
do
if [ -s $d/$file ]
then
/bin/ls$options $d/$file
exit 0
fi
done
;;
*)
file="$1"
shift
for d in $*
do
if [ -s $d/$file ]
then
/bin/ls$options $d/$file
exit 0
fi
done
;;
esac
echo >&2 "$0: $file not found"
exit 1
More information about the Alt.sources
mailing list