Bug 46561

Summary: Running Ant from command line fails if property contains a comma
Product: Ant Reporter: Mark Melvin <mark.melvin>
Component: CoreAssignee: Ant Notifications List <notifications>
Status: RESOLVED INVALID    
Severity: normal    
Priority: P2    
Version: 1.7.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   

Description Mark Melvin 2009-01-19 08:10:54 UTC
If I run the following command line (on Windows XP and Windows Server 2003):

ant.bat -Da.property=1,2,3

This fails with the message:

Target "2" does not exist in the project "test".

If I run Java with a similar command line, the property "a.property" is set to the expected value of "1,2,3".

Note that I can get Ant to succeed by double-quoting the entire argument as follows:

ant.bat "-Da.property=1,2,3"

However, this should not be necessary.  And in fact, it is not always practical.   I am running into an insurmountable issue where Ant is being called from my build server, and the build server constructs the command line.  I need a property set on the command line that contains a comma and I have no control over command line argument creation.  

Is there another way I can work around this?
Comment 1 Dominique Devienne 2009-01-19 09:29:05 UTC
Sorry, but this is not a bug. The command shell (DOS) in this case is the one interpreting the command line before Ant sees it, and the quoting to be done is Shell dependent.

We can't do anything about this. --DD
Comment 2 Mark Melvin 2009-01-19 11:03:38 UTC
Well, I think things could be worked around in Ant.bat as you are exposing the shell's argument weaknesses by rebuilding all the args using SHIFT.  This forces you to accept the result - which is that the DOS prompt splits arguments on all delimiters.  If you didn't use SHIFT you would not have the problem.  
Comment 3 Dominique Devienne 2009-01-19 15:59:48 UTC
If you can provide a functionally equivalent ant.bat which does not exhibit the issue you reported regarding comma handling, we'd gladly take it, although the Ant team is quite reticent to ant.bat changes in general since they tend to be so brittle, as you probably well know since you mention DOS' weakness in the domain.

Maybe you can substitute ant.bat for a .bat of your own doing?