The error mesage means that something started on line 48 (like a do-done, a { }, a ( ) or a if-fi) has not been completed by end of file. Have you posted the whole script? It's only 44 lines long, so there is no line 48!
All the same, I tried to scan through it looking for what wasn't closed, much helped by vim's syntax analysis which colour-codes the script. Looked OK in vim so I indented it to better see what is going on but still didn't find what is wrong. Here it is with indentation
Code:
#!/bin/sh
# inpath - Verifies that a specified program is either valid as is,
# or that it can be found in the PATH directory list.
in_path()
{
# Given a command and the PATH, try to find the command. Returns
# 0 if found and executable, 1 if not. Note that this temporarily modifies
# the IFS (input field separator) but restores it upon completion.
cmd=$1 path=$2 retval=1
oldIFS=$IFS IFS=":"
for directory in $path
do
if [ -x $directory/$cmd ] ; then
retval=0 # if we're here, we found $cmd in $directory
fi
done
IFS=$oldIFS
return $retval
}
checkForCmdInPath()
{
var=$1
# The variable slicing notation in the following conditional
# needs some explanation: ${var#expr} returns everything after
# the match for 'expr' in the variable value (if any), and
# ${var%expr} returns everything that doesn't match (in this
# case, just the very first character. You can also do this in
# Bash with ${var:0:1}, and you could use cut too: cut -c1.
if [ "$var" != "" ] ; then
if [ "${var%${var#?}}" = "/" ] ; then
if [ ! -x $var ] ; then
return 1
fi
elif ! in_path $var $PATH ; then
return 2
fi
fi
}
EDIT:
Shellscript is run, at which time it is "interpreted" so it is not "compiled".
The script as posted only contains function definitions; it never does anything ... ???