I have a script which goes as below...
some function definitions on top and one of them is...
function err_out
{
trap 'echo "ERROR in $STEP function. EXITING!";exit 1' ERR
#some more messages
exit 1
}
# Main program starts here
trap 'err_out' ERR
#do something
#call some functions
#call cleanup function
#end of script
when ever some error happens in the functions, they are not propagated and err_out function is not called.
I tried #!/bin/bash -E too; that way when there is an error the script exits but what I need is error to be propagated properly to the handler.