Avoid recursion for relative paths
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
diff --git a/tests/scripts/quiet/quiet.sh b/tests/scripts/quiet/quiet.sh
index 30ee569..b143230 100644
--- a/tests/scripts/quiet/quiet.sh
+++ b/tests/scripts/quiet/quiet.sh
@@ -22,9 +22,16 @@
# be silenced, e.g. " --version | test ". In this example, "make lib test" will
# not be silent, but "make lib" will be.
-# Locate original tool
-TOOL_WITH_PATH=$(dirname "$0")/$TOOL
-ORIGINAL_TOOL=$(type -ap "${TOOL}" | grep -v -Fx "$TOOL_WITH_PATH" | head -n1)
+# Function to normalise paths
+get_real_filename() {
+ leafname="$(basename "$1")"
+ ( cd $(dirname "$1"); echo "$(pwd)/$leafname" )
+}
+
+# Normalise path to wrapper script
+WRAPPER_WITH_PATH=$(get_real_filename "$0")
+# Identify original tool (compare normalised path to WRAPPER_WITH_PATH to avoid recursively calling the same wrapper script)
+ORIGINAL_TOOL="$(for p in $(type -ap "$TOOL"); do get_real_filename "$p" ; done | grep -v -Fx "$WRAPPER_WITH_PATH" | head -n1)"
print_quoted_args() {
# similar to printf '%q' "$@"