From 1fbd34035e90f0ae8a93ee665cf0be5c16899227 Mon Sep 17 00:00:00 2001 From: John Reiser Date: Sun, 6 Jul 2025 19:21:26 -0700 Subject: [PATCH] shell trap on ERR to help locate failing commands modified: misc/testsuite/mimic_ctest.sh --- misc/testsuite/mimic_ctest.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/misc/testsuite/mimic_ctest.sh b/misc/testsuite/mimic_ctest.sh index d8e8d2b0..2881ff4b 100755 --- a/misc/testsuite/mimic_ctest.sh +++ b/misc/testsuite/mimic_ctest.sh @@ -16,6 +16,12 @@ argv0=$0; argv0abs=$(readlink -fn "$argv0"); argv0dir=$(dirname "$argv0abs") # $upx_exe_runner (e.g. "qemu-x86_64 -cpu Nehalem" or "valgrind") # +# Debugging aid for locating failing commands. Depends on 'bash' shell. +# (BASH_LINENO is relative to current FUNCTION only; non-function ==> 0) +# Notice single-quoting of entire first argument. +trap 'echo ERROR: pwd=\"$PWD\" file=\"$BASH_SOURCE\" line=${BASH_LINENO[0]} cmd=\"$BASH_COMMAND\"' ERR +# Example: "false a b c" ==> ERROR: pwd="path/misc/testsuite" file="./mimic_ctest.sh" line=0 cmd="false a b c" + #*********************************************************************** # init & checks #***********************************************************************