Hi,
Is there a way to exit from a subcommand, which is a function in my example below?
#!/bin/ksh
function exitFunction {
if [[ $1 -eq 1 ]]; then
echo "success"
elif [[ $1 -eq 0 ]]; then
echo "failed"
exit 1 # the exit problem
fi
exit 0
}
testVar=`exitFunction 1`
echo $testVar
testVar2=`exitFunction 0`
echo $testVar2
echo "this message should not be shown."
exit 0
The result of my script:
success
failed
this message should not be shown.
It should exit right after the "failed" message, but it it's not.
I appreciate your help.