Im having issues where the EXIT Trap
command is not seeing my exit
code. Ive tried just setting a $var
from 0
to 1
and right now I'm trying to override the exit
with a 1
and base on that having the trap
command run certain code.
#!/bin/bash
if [[ 0 -ge 1 ]]; then
echo "run code"
else
echo "oops.. dont like what I see"
exit 1
fi
finish() {
sleep 5
term=$?
if [[ $term -eq 0 ]]; then
echo pass
else
echo fail
fi
}
trap 'finish' EXIT
When I troubleshoot the code. term
is being assign to 0
when exit
is triggered.