I'm not using set -e in my shell script, i'm handling each specific error with a function (event). In this particular case i'm trying to (insert a database and) catch any errors from mysql if it fails. Then send it straight into my event function so i can store it in a logfile.
mysql $schema < 'structure_dump.sql' || event "8" "$schema structure insert failed:"
I thought that output would be caught by doing this, but my error variable appears empty when this fails even though i'm still getting the mysql error message on my screen.
err=$(mysql $schema < 'structure_dump.sql') || event "8" "$schema structure insert failed: $err"
Is it possible to do this or am i thinking about it in the wrong way?