Exit a bash script from a function whose output is captured

view story

http://stackoverflow.com – I want to completely terminate/exit a bash shell script upon error, but using a function error that lets me display a debug output before termination. Now I have the problem that the exit 1 statement inside the error function will not terminate the shell script if the function's output is captured via backticks or $(). Here is my sample script: #!/bin/bash function error () { echo "An error has occured: $1" exit 1 } function do_sth () { if [ $1 -eq 0 ]; then error "First param must be greater than 0!" (HowTos)