I don't know what is wrong with my function; it is not returning value properly.
function validate_directory_isempty {
retval=""
NumOfFiles=`ls -l $input | egrep -c "^-"`
if [ "$NumOfFiles" == "0" ];then
retval=true
else
retval=false
fi
echo $retval
}
retval=$(validate_directory_isempty /opt/InstallationManager)
echo "retval : " $retval
if [ "$retval" == "true" ]; then
echo ""
echo "Installing Installation Manager"
# Install_IM
else
echo ""
echo "DIRECTORY is not empty. Please make sure install location $DIRECTORY is empty before installing PRODUCT"
fi
{}button above the edit box to indent it 4 spaces, but the body of your function shouldn't be 30-odd spaces indented.inputis not defined invalidate_directory_isempty$inputis not defined in the function. The arguments to the function are in$1etc; you probably want to replace$inputwith"$@". Also note that thefunctionnotation is not preferred; POSIX would usevalidate_directory_isempty() { ...code as fixed... }.