fix bug after a bash completion
[errhandle.git] / err
diff --git a/err b/err
index 132a137eb2269b7112b221149253a8e5da01aa0b..5d15407638146dedb81aa36783940e8efb8edcf4 100644 (file)
--- a/err
+++ b/err
@@ -95,12 +95,20 @@ err-catch() {
 #######################################
 
 _err-bash-trace-interactive() {
+  if (( ${#FUNCNAME[@]} <= 1 )); then
+    return 0
+  fi
+
+  for pattern in "${err_catch_ignore[@]}"; do
+    # shellcheck disable=SC2053
+    if [[ ${BASH_SOURCE[1]} == $pattern ]]; then
+      return 0
+    fi
+  done
+
   local ret bash_command argc pattern i last
   last=$_err_func_last
   _err_func_last=${#FUNCNAME[@]}
-  if (( _err_func_last <= 1 )); then
-    return 0
-  fi
   # We have these passed to us because they are lost inside the
   # function.
   ret=$1
@@ -108,12 +116,6 @@ _err-bash-trace-interactive() {
   argc=$(( $3 - 1 ))
   shift 3
   argv=("$@")
-  for pattern in "${err_catch_ignore[@]}"; do
-    # shellcheck disable=SC2053
-    if [[ ${BASH_SOURCE[1]} == $pattern ]]; then
-      return 0
-    fi
-  done
   # The trap returns a nonzero, then gets called again. This condition
   # tells us if we are the first.
   if (( _err_func_last > last  )); then