Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail From: Steven Simpson Newsgroups: comp.lang.java.programmer Subject: Re: exec problem is JDK 1.7.0_21 Date: Tue, 23 Apr 2013 23:39:23 +0100 Organization: A noiseless patient Spider Lines: 56 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: mx05.eternal-september.org; posting-host="847c23adf71594bde0de355f9bb56936"; logging-data="17244"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19oGWgoYGZD/egic9QisrY0dCWB8APk3RA=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 In-Reply-To: Cancel-Lock: sha1:JvhNx0c5ZVlIsb5c7+AW/TdTWqU= Xref: csiph.com comp.lang.java.programmer:23604 On 23/04/13 21:31, Sven Köhler wrote: > Am 23.04.2013 21:56, schrieb Steven Simpson: >> $ java WindowsArgumentGenerator 'c:\program files\\\' 'world' >> argv[0]=[c:\program files\\\] >> argv[1]=[world] >> "c:\program files"\\\ world > That doesn't look right. A correct escaping would be > "c:\program files\\\\\\" world > > You have to double the number of backslashes if they preceed a quote. I took it to mean that such a quote is literal, and should be present in the string provided by argv. If I were to pass that line to CommandLineToArgvW, I would expect it either to fail because the first (and only) argument is quoted, but does not have a closing quote, or succeed by inferring the missing quote, yielding the following list of one argument: c:\program files\\\" world > Also, you have to add another backslash if the quote does not terminate > the argument. Again, I took it to mean that the first two rules produce the same result, so \\\" and \\" both produce \". > Here's my attempt to the do the escaping: > http://sourceforge.net/p/lejos/code/HEAD/tree/trunk/org.lejos.nxt.ldt/src/main/java/org/lejos/nxt/ldt/util/LeJOSNXJUtil.java#l421 I haven't looked in detail at it, but do note your comment: > * How decoding works: > * 2n backslashes + quote => n backslashes + closing quote > * 2n+1 backslashes + quote => n backslashes + inner quote > * n backslashes not followed by a quote => n backslashes From (with my emphasis): > > * 2/n/ backslashes followed by a quotation mark produce /n/ > backslashes followed by a quotation mark. > * (2/n/) + 1 backslashes followed by a quotation mark *again* > produce /n/ backslashes followed by a quotation mark. > * /n/ backslashes not followed by a quotation mark simply produce > /n/ backslashes. > > Where are you getting the notion that the first two rules imply different quotes? I interpret both as being literal (inner, right?). -- ss at comp dot lancs dot ac dot uk