Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 38937 invoked from network); 8 Feb 2011 08:14:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 8 Feb 2011 08:14:23 -0000 Received: (qmail 90768 invoked by uid 500); 8 Feb 2011 08:14:23 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 90261 invoked by uid 500); 8 Feb 2011 08:14:19 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 90253 invoked by uid 99); 8 Feb 2011 08:14:18 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Feb 2011 08:14:18 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Feb 2011 08:14:17 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 73F1B199A23 for ; Tue, 8 Feb 2011 08:13:57 +0000 (UTC) Date: Tue, 8 Feb 2011 08:13:57 +0000 (UTC) From: =?utf-8?Q?Jeremias_R=C3=B6=C3=9Fler_=28JIRA=29?= To: issues@commons.apache.org Message-ID: <648953916.1915.1297152837471.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] Created: (EXEC-54) Problem with argument containing spaces MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Problem with argument containing spaces --------------------------------------- Key: EXEC-54 URL: https://issues.apache.org/jira/browse/EXEC-54 Project: Commons Exec Issue Type: Bug Affects Versions: 1.1 Environment: Mac OsX 10.6.6, JVM 1.6.0 Reporter: Jeremias R=C3=B6=C3=9Fler I am new to Commons Exec, so this could also be an error in usage, but...= =20 When I use the {{CommandLine}} class to add a argument that contains spaces= , some quotes are added and are then part of the argument that is given. For example: When I call {{java "what version"}} I get {{java.lang.NoClassD= efFoundError: what version}}, and when I call {{java "\"what version\""}} (= which contains escaped quotes, that are part of the command line argument i= tself), I get {{java.lang.NoClassDefFoundError: "what version"}}. So the following test fails, because as you can see in the last line, Apach= e Exec is producing the latter version where it should have produced the fi= rst version: {code:java} =09@Test =09public void testArgumentQuoting() throws Exception { =09=09String argument =3D "what version"; =09=09DefaultExecutor executor =3D new DefaultExecutor(); =09=09DefaultExecuteResultHandler resultHandler =3D new DefaultExecuteResul= tHandler(); =09=09ByteArrayOutputStream out =3D new ByteArrayOutputStream(); =09=09PumpStreamHandler streamHandler =3D new PumpStreamHandler(out, out); =09=09executor.setStreamHandler(streamHandler); =09=09CommandLine cmdLine =3D new CommandLine("java"); =09=09cmdLine.addArgument(argument); =09=09executor.execute(cmdLine, resultHandler); =09=09resultHandler.waitFor(); =09=09String resultPattern =3D "Exception in thread \"main\" java\\.lang\\.= NoClassDefFoundError: ([\\w \"]+)"; =09=09Pattern pattern =3D Pattern.compile(resultPattern); =09=09Matcher matcher =3D pattern.matcher(out.toString()); =09=09Assert.assertTrue(matcher.find()); =09=09// Note: Result should be and NOT <"what version">! =09=09Assert.assertEquals(argument, matcher.group(1)); =09} {code}=20 Note that the same test passes if the space is removed from the argument. P= lease also note, that I am not trying to start an external Java process, bu= t this is merely an example that I assume will work on every developers mac= hine. --=20 This message is automatically generated by JIRA. - For more information on JIRA, see: http://www.atlassian.com/software/jira