I am using set -e
to stop execution of a script on first error.
The problem is that this does not tell me what went wrong.
How can update a bash scr
You can't use set -e
by itself because processing will immediately stop after any error. Take a look at the Set Builtin section of the Bash Reference Manual for more information about the -x and -v options, which you can use for debugging.
Something like:
set -e
set -v
will exit on any error, while showing you each input line as it is read. It will not, however, show you just the line with the error. For that, you will need to do your own explicit error checking.
For example:
set +e
if false; then
real_exit_status=$?
echo 'Some useful error message.' >&2
exit $real_exit_status
fi