Path: csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail From: Martin Gregorie Newsgroups: comp.lang.java.programmer Subject: Re: exec problem is JDK 1.7.0_21 Date: Wed, 24 Apr 2013 20:22:44 +0000 (UTC) Organization: A noiseless patient Spider Lines: 33 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Wed, 24 Apr 2013 20:22:44 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="023384c1aa284d1305afa0f48d0dff5a"; logging-data="21976"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/xPvCT3a2tnF2h18sJYOrTOuXTtBCI1uY=" User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Cancel-Lock: sha1:6tpxIvmXyOY2Ba9JH/Fi0s2r5II= Xref: csiph.com comp.lang.java.programmer:23631 On Wed, 24 Apr 2013 11:22:14 +0300, Sven Köhler wrote: > On 04/24/2013 12:05 AM, Martin Gregorie wrote: >> Actually, on Linux almost all the messing about with strings is done by >> the shell that invokes the the command if the strings are enclosed in >> double quotes. Use single quotes instead and the strings arrive at the >> program ProcessBuilder is running with no modification at all. Here are >> the results of using (1) double quoted strings and (2) single quoted >> strings. > > I don't know what you mean. On Linux (or other UNIX-like operating > systems), you specify the command line parameters as an array of strings > when executing an external program. There is by definition no "messing > about" with strings. Whatever syntax the shell uses to escape quotes and > backslashes is irrelevant to ProcessBuilder, as it doesn't use the shell > to start programs, but rather invokes some flavor of the exec function > directly. > It is not irrelevant if, as my test case does, you specify the ProcessBuilder arguments as part of a bash shell command. In these circumstances if you want ProcessBuilder to use exactly the argument content you wrote you must enclose the argument in single quotes to prevent the substitutions, etc the shell applies to unquoted words or to double-quoted arguments. If you do this you'll then see that neither the ProcessBuilder constructor nor the way ProcessBuilder passes the arguments to the program being called make any changes to the content of the arguments. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |