Is there some way for a bash script to explicitly trigger a trap that is looking for an ERR signal (which is a special signal that can be explicitly called via kill
, see https://stackoverflow.com/a/26261518/8236733)?
Have a trap file of the form
#!/bin/bash
error() {#do stuff like alert people via email}
trap 'error ${LINENO} $tablename' ERR
and a script of the form
#!/bin/bash
# trap to catch errors
source '/home/mapr/etl_scripts/clarity/lib.trap.sh'
{#try stuff} || {#catch stuff; exit 1;}
I had thought that the exit 1
would be enough to signal the trap, but this does not seem to be the case. Is there some other way to intentionally trigger the trap from within the script? Thanks.