Skip to content

Instantly share code, notes, and snippets.

@thapakazi
Created November 30, 2022 21:09
Show Gist options
  • Save thapakazi/9afa51bc68f66b178de43f4feaffad42 to your computer and use it in GitHub Desktop.
Save thapakazi/9afa51bc68f66b178de43f4feaffad42 to your computer and use it in GitHub Desktop.
#!/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