readded udpated scripts directory
This commit is contained in:
parent
cd053a412a
commit
f3117c81d9
84 changed files with 3210 additions and 0 deletions
52
scripts/inpath
Executable file
52
scripts/inpath
Executable file
|
|
@ -0,0 +1,52 @@
|
|||
#!/bin/bash
|
||||
# inpath--Verifies that a specified program is either valid as is
|
||||
# or can be found in the PATH directory list
|
||||
|
||||
in_path()
|
||||
{
|
||||
# Given a command and the PATH, tries to find the command. Returns 0 if
|
||||
# found and executable; 1 if not. Note tha this temporarily modifies
|
||||
# the IFS (internal field separator) but restores it upon completion.
|
||||
|
||||
cmd=$1 ourpath=$2 result=1
|
||||
oldIFS=$IFS IFS=":"
|
||||
|
||||
for directory in $ourpath
|
||||
do
|
||||
if [ -x $directory/$cmd ] ; then
|
||||
result=0 # If we're here, we found the command.
|
||||
fi
|
||||
done
|
||||
|
||||
IFS=$oldIFS
|
||||
return $result
|
||||
}
|
||||
|
||||
checkForCmdInPath()
|
||||
{
|
||||
var=$1
|
||||
|
||||
if [ "$var" != "" ] ; then
|
||||
if [ "${var:0:1}" = "/" ] ; then
|
||||
if [ ! -x $var ] ; then
|
||||
return 1
|
||||
fi
|
||||
elif ! in_path $var "$PATH" ; then
|
||||
return 2
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
#if [ $# -ne 1 ]; then
|
||||
#echo "Usage: $0 command" >&2
|
||||
#exit 1
|
||||
#fi
|
||||
|
||||
#checkForCmdInPath "$1"
|
||||
#case $? in
|
||||
#0 ) echo "$1 found in PATH" ;;
|
||||
#1 ) echo "$1 not found or not executable" ;;
|
||||
#2 ) echo "$1 not found in PATH" ;;
|
||||
#esac
|
||||
|
||||
#exit 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue