when I run the follow bash script, it will never print "bye!". It seems that return statement in dummy function will cause the bash script end, leave the left script not excute.
#!/bin/bash -ex
dummy () {
if [ $1 -eq 0 ] ; then
return 0
else
return 55
fi
}
dummy 0
echo "when input 0, dummy will return $?"
dummy 50
echo "when input 50, dummy will return $?"
echo "bye!"
output:
+ dummy 0
+ '[' 0 -eq 0 ']'
+ return 0
+ echo 'when input 0, dummy will return 0'
when input 0, dummy will return 0
+ dummy 50
+ '[' 50 -eq 0 ']'
+ return 55