could somebody tell me please how to exit a shell script:
if [ $# -eq 0 ]
then
echo "No arguments detected"
exit 1
fi
...
echo "still there" # is displayed ..
could somebody tell me please how to exit a shell script:
if [ $# -eq 0 ]
then
echo "No arguments detected"
exit 1
fi
...
echo "still there" # is displayed ..
if [ $# -eq 0 ]
then
echo "No arguments detected"
exit 1 #exit shell script
fi
...
echo "still there" # is displayed .. :-(
sorry...... I have the following situation and it does not work :
if [ $# -eq 0 ]
then
usage()
fi
echo "still there.."
usage {
echo "No arguments detected"
exit 1 #exit shell script
}
Try this..
function usage {
echo "No arguments detected"
exit 1 #exit shell script
}
if [ $# -eq 0 ]
then
usage
fi
echo "still there.."
Function must be declared before it is used in script.try the below script..
usage ()
{
echo "No arguments detected"
exit 1 #exit shell script
}
if [ $# -eq 0 ];
then
usage
fi
echo "still there.."