Hi, I am working on a script and ran into an unusual program. Consider the following script which I called how.sh.
===== #!/bin/bash error () { echo -e "\n\terror: ${*}\n" exit; # kill $$ } check_file () { input="$*" if [ -e $input ]; then echo "$input" else error "invalid directory: $input" fi } chkFile="`check_file $1`" echo $chkFile echo "don't print" ===== When I run the command above I get this output: # ./how.sh /asdf error: invalid directory: /asdf don't print The intention of the script is not to print the second echo statement. I've tried changing the first echo with exec and eval and also adding these commands before the call to check_file in the variable assignment, but to no avail. The error() function is suppose to print the error, and completely exit the script. One alternative is to use the kill statement, however this route does not print the error message and prints the "termination" message. How can the problem I'm having exiting the application be solved? I'd like to resulting code to be as clean as possible, and make all error messages go through the error() function. Thanks in advance. Abi