add directory bin
This commit is contained in:
57
bin/old/bash-1.11/examples/functions/whence2
Normal file
57
bin/old/bash-1.11/examples/functions/whence2
Normal file
@@ -0,0 +1,57 @@
|
||||
#
|
||||
# An almost-ksh compatible `whence' command. The one difference between this
|
||||
# and the real ksh `whence' is that this version, when the "-v" flag is not
|
||||
# given and presented with something that is not in the path, simply echos it
|
||||
# without more checking to see if it is a function, builtin, or alias.
|
||||
#
|
||||
# Chet Ramey
|
||||
# chet@ins.CWRU.Edu
|
||||
#
|
||||
|
||||
|
||||
whence()
|
||||
{
|
||||
local vflag
|
||||
local path
|
||||
|
||||
vflag=
|
||||
path=
|
||||
if [ $# = "0" ] ; then
|
||||
echo "whence: argument expected"
|
||||
return 1
|
||||
fi
|
||||
case "$1" in
|
||||
-v) vflag=1
|
||||
shift 1
|
||||
;;
|
||||
-*) echo "whence: bad option: $1"
|
||||
return 1
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
|
||||
if [ $# = "0" ] ; then
|
||||
echo "whence: bad argument count"
|
||||
return 1
|
||||
fi
|
||||
|
||||
for cmd
|
||||
do
|
||||
if [ "$vflag" ] ; then
|
||||
echo $(builtin type $cmd | sed 1q)
|
||||
else
|
||||
path=$(builtin type -path $cmd)
|
||||
if [ "$path" ] ; then
|
||||
echo $path
|
||||
else
|
||||
case "$cmd" in
|
||||
/*) echo ""
|
||||
;;
|
||||
*) echo "$cmd"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
Reference in New Issue
Block a user