Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.swapon.de!fu-berlin.de!uni-berlin.de!news.dfncis.de!not-for-mail From: =?ISO-8859-1?Q?Sven_K=F6hler?= Newsgroups: comp.lang.java.programmer Subject: Re: exec problem is JDK 1.7.0_21 Date: Mon, 22 Apr 2013 19:33:10 +0300 Lines: 31 Message-ID: References: <73df4a-rc3.ln1@s.simpson148.btinternet.com> <60cdt.4948$sI.1833@newsfe20.iad> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: news.dfncis.de Vf7cdTFQOOTqa+J06olcWglToHBkwaHSiB3pK5sKuq91h+bSeYcxZTmgBU Cancel-Lock: sha1:e07xuuCPp7BbcWdlqso2cR8nUVc= User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 In-Reply-To: <60cdt.4948$sI.1833@newsfe20.iad> Xref: csiph.com comp.lang.java.programmer:23568 Am 22.04.2013 17:43, schrieb Daniel Pitts: > On 4/22/13 2:39 AM, Steven Simpson wrote: >> test("showargs", "hello world"); >> test("showargs", "\"hello world\""); >> test("showargs", "\"hello\" \"world\""); >> test("showargs", "\"\\\"hello world\\\"\""); Here are several other interesting ones: test("showargs", "hello\" \" world"); test("showargs", "hello", "", "world"); test("showargs", "hello", "\"\"", "world"); test("showargs", "c:\\program files\\", "world"); test("showargs", "c:\\program files\\\\", "world"); test("showargs", "c:\\program files\\\\\\", "world"); > Interesting, I expected the argv[1]=["hello world"] for the input "hello > world"]. It seems to be that way for Linux, but not on windows. On Linux, the strings can be passed between processes "as-is" - without adding quotes, escapes, or whatever. But on Windows, adding quotes and escaping quotes that are part of the argument may be necessary. The current ProcessBuilder implementation sucks at it. Also, no definitive way of escaping quotes or backslashes exists, as each program could use a different tokenizer. In practise, it's usually something compatible to Microsoft's CommandLineToArgv function. Regards, Sven