Permalink
Browse files

Bugfix: Quote in a posix compliant manner

  • Loading branch information...
1 parent 8d78742 commit 46ad46e60a2cca98dae57ce7848e62ceecbd41cb @tamiko tamiko committed Jan 8, 2017
Showing with 10 additions and 2 deletions.
  1. +10 −2 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

0 comments on commit 46ad46e

Please sign in to comment.