From 568c3eeb96badf1e47380fd3e641cfc9a9ee935e Mon Sep 17 00:00:00 2001 From: Jeffrey Adamson Date: Wed, 20 Jan 2016 16:14:48 -0500 Subject: [PATCH] Bug 58898: Ant fails to run when arguments contain double-quote character Test with lots of args that break existing script ./ant --execdebug -Df='"' -Dx="'" "-Dx='" -Dz=\'\""'" --- src/script/ant | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/script/ant b/src/script/ant index 4c1f7509b..6baf1212b 100644 --- a/src/script/ant +++ b/src/script/ant @@ -35,7 +35,8 @@ for arg in "$@" ; do if [ my"$arg" = my"-h" -o my"$arg" = my"-help" ] ; then show_help=true fi - ant_exec_args="$ant_exec_args \"$arg\"" + # wrap all arguments as "" strings, escape any internal back-slash or double-quote characters + ant_exec_args="$ant_exec_args \"$(printf '%s' "$arg" | sed -e 's@"\|\\@\\\0@g' )\"" fi done @@ -333,4 +334,5 @@ ant_exec_command="exec \"\$JAVACMD\" $ANT_OPTS -classpath \"\$LOCALCLASSPATH\" - if $ant_exec_debug ; then echo $ant_exec_command $ant_exec_args fi -eval $ant_exec_command "$ant_exec_args" + +eval $ant_exec_command $ant_exec_args