You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2013/02/12 07:54:16 UTC

[Bug 23273] Java task interprets it's arguments incorrectly if terminated with \\

https://issues.apache.org/bugzilla/show_bug.cgi?id=23273

--- Comment #8 from Vincent Belaïche <vi...@hotmail.fr> ---
Please have look at the bug which I filed #54285 (please note that the
description of the bug is entered with Jira markup, this is because I initially
did a mistake and filed the bug on ivy jira).

The root problem is the way how MSWindows escapes double quotes: to escape a
double quote you have to do this way:

Let N be the number of backslash(es) preceding the double quote to be escaped
(with N>=0), then replace the N backslash(es) by 2*N+1 backslash(es) and your
double quote gets escaped.

Now, the thing is that a group of N tailing backslahes, N>=1, is to be
considered as followed by a double quote --- that double-quote that is part of
the whole argument quoting --- so they must also be replaced by 2*N+1
backslashes.

The problem is that I could not find that this escaping technique is documented
anywhere except in some discussion forum. Furthermore you can also quote one
double quotes by replacing by 3 consecutive double quotes, and that works when
there are no backslash --- so some people do that and everybody gets confused.

Now the question is whether this is a problem of Ant, or a problem of the JVM.
I would tend to think that this is not a problem of the JVM, and that you have
to pass to the JVM a command line that is correctly formatted for the
underlying platform --- just like in a GNU Makefile shell commands have to
follow the shell syntax. This means that you need some class to do platform
dependent command-line formatting --- this is what is missing in the standard
JAVA libraries. Then this standard class could be deployed differently
depending on the platform. So, in my opinion this is more an issue of standard
JAVA library than of pure JVM implementation --- well one could also consider
that the JVM comprises a set of standard libraries, but I think that this is
not correct wording.

I proposed some code to do the escaping for one argument. I think one has to
see what is the intention on the JVM/Standard library side before to take any
decision. Maybe they do something new that would solve the problem more easily.
But then there should also be some way to keep Ant executable on older JVM
deployments. So maybe the temporary solution is to do the platform escaping job
by some Ant own code.

Anyway, I suggest to mark this bug as duplicate with #54285

-- 
You are receiving this mail because:
You are the assignee for the bug.