From 46ad46e60a2cca98dae57ce7848e62ceecbd41cb Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Sun, 8 Jan 2017 17:10:25 -0600 Subject: [PATCH] Bugfix: Quote in a posix compliant manner --- cmake/scripts/run_test.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cmake/scripts/run_test.sh b/cmake/scripts/run_test.sh index 72a39a7a81..53c82727f7 100644 --- a/cmake/scripts/run_test.sh +++ b/cmake/scripts/run_test.sh @@ -31,7 +31,14 @@ NUMDIFF_EXECUTABLE="$3" DIFF_EXECUTABLE="$4" COMPARISON_FILE="$5" shift 5 -RUN_COMMAND=( "$@" ) + +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; + done + echo " " +} + +RUN_COMMAND=$(save "$@") # Ensure uniform sorting for pathname expansion export LC_ALL=C @@ -45,7 +52,8 @@ run(){ rm -f output rm -f stdout - "${RUN_COMMAND[@]}" > stdout 2>&1 + eval "set -- ${RUN_COMMAND}" + "$@" > stdout 2>&1 RETURN_VALUE=$? [ -f output ] || mv stdout output -- 2.39.5