Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!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 09:36:46 +0300 Lines: 36 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: news.dfncis.de t8tU/nU6dkVdlIAPydGm4Qih7BA8CtVZrHuKZUwj2noK/nMVUDFsi6EWk5 Cancel-Lock: sha1:3k0aHDGWTcPmHH7Cg8uBBXV4FAA= User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:23564 Am 22.04.2013 04:49, schrieb Knute Johnson: > On 4/21/2013 1:29 PM, Sven Köhler wrote: >> Am 21.04.2013 19:20, schrieb Knute Johnson: >>> One quoted argument "hello world" >> >> new ProcessBuilder("test.exe", "hello world"); >> new ProcessBuilder("test.exe", "\"hello world\""); >> new ProcessBuilder("test.exe", "\"hello\" \"world\""); >> >> Run that on Windows as well as on something UNIX like - e.g. Linux. > > I think ProcessBuilder strips out the quotes inside the String. The > little C program I wrote deals with them just fine from the command line > in XP. The output should have been: 1) argv[1]=hello world 2) argv[1]=hello world 3) argv[1]=hello argv[2]=world And in the fourth example I added, the output should have been 4) argv[1]="hello world" ProcessBuilder does not strip any quotes. The logic it implements is as follows: If the argument contains spaces, add quotes. If it already starts/ends with a quote, don't modify it. ProcessBuilder does not check, escape, or do anything else with quotes inside the argument string. You can confirm that by looking at the sources available in the JDK. Regards, Sven