Tuesday, January 06, 2009

Trapping errors in bash

Bash has functionality similar to exceptions in java.
If we want to handle any sort of error, we can add a handler function
and exit with an error code. This sure beats checking exit code
after every command.

function error {
echo Error
exit 1
}
trap error ERR

No comments: