I sometimes include this function in my scripts:
function abort {
echo $@; exit 1
}
It's nice to have a print-and-exit notation contained in a single command. However, when sourcing scripts, exit
kills the shell and return
does nothing from within the function.
How can I redefine abort()
to work in sourced scripts?