X-Git-Url: https://iankelling.org/git/?p=distro-setup;a=blobdiff_plain;f=switch-mail-host;h=10fcd9f12d82c580e1ee3536c2ac51ed08e9c969;hp=e52abdb45326c9617697e591e7f5d9b3e62d1a9e;hb=1059b8ac11f567b9a8eec1e34a7ab6e791721dca;hpb=77616920035e0e7c64d54b447df397822dc4370c diff --git a/switch-mail-host b/switch-mail-host index e52abdb..10fcd9f 100644 --- a/switch-mail-host +++ b/switch-mail-host @@ -1,50 +1,6 @@ #!/bin/bash -err-bash-trace() { - local -i argc_index=0 frame i start=${1:-0} max_indent=8 indent - local source - local extdebug=false - if [[ $(shopt -p extdebug) == *-s* ]]; then - extdebug=true - fi - for ((frame=0; frame < ${#FUNCNAME[@]}-1; frame++)); do - argc=${BASH_ARGC[frame]} - argc_index+=$argc - ((frame < start)) && continue - if (( ${#BASH_SOURCE[@]} > 1 )); then - source="${BASH_SOURCE[frame+1]}:${BASH_LINENO[frame]}:" - fi - indent=$((frame-start + 1)) - indent=$((indent < max_indent ? indent : max_indent)) - printf "%${indent}s↳%sin \`%s" '' "$source" "${FUNCNAME[frame]}" - if $extdebug; then - for ((i=argc_index-1; i >= argc_index-argc; i--)); do - printf " %s" "${BASH_ARGV[i]}" - done - fi - echo \' - done - return 0 -} - - -err-catch() { - set -E; shopt -s extdebug - _err-trap() { - err=$? - exec >&2 - set +x - echo "${BASH_SOURCE[1]}:${BASH_LINENO[0]}: \`$BASH_COMMAND' returned $err" - err-bash-trace 2 - set -e # err trap does not work within an error trap - "${_errcatch_cleanup[@]:-:}" # note :-: is to be compatible with set -u - echo "$0: exiting with code $err" - exit $err - } - trap _err-trap ERR - set -o pipefail -} -err-catch +source /usr/local/lib/err usage() { cat <