Created
November 30, 2022 21:09
-
-
Save thapakazi/9afa51bc68f66b178de43f4feaffad42 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
stderr_log="/tmp/stderr.log" | |
exec 2>"$stderr_log" | |
notify() { | |
local exit_code=$? | |
local lineno=$1 | |
if ! [ $exit_code -eq 0 ]; then | |
#echo "Failed at $lineno with $exit_code" | |
tail -n 5 $stderr_log | |
else | |
echo "ALL IS WELL: $exit_code" | |
fi | |
} | |
trap 'notify $LINENO' ERR | |
ls -la | asdf | |
lsa -la | |
pwd | |
uptime | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment