You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by an...@apache.org on 2016/02/22 04:40:47 UTC

[2/4] ant git commit: Bug 58898: Ant fails to run when arguments contain double-quote character

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=\'\""'"


Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/568c3eeb
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/568c3eeb
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/568c3eeb

Branch: refs/heads/master
Commit: 568c3eeb96badf1e47380fd3e641cfc9a9ee935e
Parents: 14e71c1
Author: Jeffrey Adamson <jw...@us.ibm.com>
Authored: Wed Jan 20 16:14:48 2016 -0500
Committer: Jeffrey Adamson <jw...@us.ibm.com>
Committed: Wed Jan 20 16:14:48 2016 -0500

----------------------------------------------------------------------
 src/script/ant | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/568c3eeb/src/script/ant
----------------------------------------------------------------------
diff --git a/src/script/ant b/src/script/ant
index 4c1f750..6baf121 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