+#######################################
+# Internal function for err-catch-interactive.
+# Prints stack trace from interactive shell trap.
+# Usage: see err-catch-interactive
+#######################################
+
+_err-bash-trace-interactive() {
+ local ret bash_command argc pattern i
+ # We have these passed to us because they are lost inside the
+ # function.
+ ret=$1
+ bash_command="$2"
+ argc=$(( $3 - 1 ))
+ shift 3
+ argv=("$@")
+ for pattern in "${err_catch_ignore[@]}"; do
+ # shellcheck disable=SC2053
+ if [[ ${BASH_SOURCE[0]} == $pattern ]]; then
+ return 0
+ fi
+ done
+ if (( ${#FUNCNAME[@]} > _err_func_last )); then
+ echo ERR: \`$bash_command\' returned $ret
+ fi
+ _err_func_last=${#FUNCNAME[@]}
+ if (( _err_func_last > 1 )); then
+ printf " from \`%s" "${FUNCNAME[1]}"
+ if shopt extdebug >/dev/null; then
+ for ((i=argc; i >= 0; i--)); do
+ printf " %s" "${argv[i]}"
+ done
+ fi
+ printf "\' defined at %s:%s\n" "${BASH_SOURCE[1]}" "$(declare -F "${FUNCNAME[1]}"|awk "{print \$2}")"
+ return $ret
+ fi
+}
+