Skip to content

Instantly share code, notes, and snippets.

@airtower-luna
Created March 5, 2017 17:09
Show Gist options
  • Save airtower-luna/5039f60b0e2042f29f8d792bb79fec61 to your computer and use it in GitHub Desktop.
Save airtower-luna/5039f60b0e2042f29f8d792bb79fec61 to your computer and use it in GitHub Desktop.
Example script: Bash caller builtin lists wrong lineno/function in ERR trap triggered by return
#!/bin/bash -E
function commanderr
{
false
}
function returnerr
{
return 1
}
function calltrace ()
{
local l=0
echo -n "${l}: "
while caller $((l++)); do echo -n "${l}: "; done
echo -n -e "\r"
}
trap 'calltrace' ERR
commanderr
returnerr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment