Created attachment 6541 [details] return exits shell When return is the first command in the else block inside of a function the shell exits. It does not exit if return is the second command. This only seems to happen if the -e flag is set. See attachment for test case. If you make this change, it starts working again: if false ; then echo "false" else echo "anything" return fi
bash 3.x and 4.x works the same. "return" with no exitcode uses exitcode of the last command, in this case "false" sets exitcode to 1. with -e, such return qualifies as failing command, and it makes shell exit.