Skip to content

Instantly share code, notes, and snippets.

@thapakazi
Created November 30, 2022 21:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
#!/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