commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mitko Kolev (JIRA)" <j...@apache.org>
Subject [jira] Issue Comment Edited: (EXEC-36) CommandLine does not work with double quote or single quote correctly
Date Thu, 08 Apr 2010 21:48:36 GMT

    [ https://issues.apache.org/jira/browse/EXEC-36?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12855165#action_12855165
] 

Mitko Kolev edited comment on EXEC-36 at 4/8/10 9:48 PM:
---------------------------------------------------------

Hello everyone,
I am using the commons-exec library in Apache Camel (the command arguments must be parsed
from a URI), came up to the same problem, and had to implement the parsing myself. I did the
custom command line args parsing based on the following 3 simple rules: 

* The args in the line are space-separated tokens
* If an argument has a space itself, this space can be quoted with " (double-qoute)
* If an argument should preserve the double-quotes, it is quoted two times with a double-quote

Here is [a link to to the parser|https://svn.apache.org/repos/asf/camel/trunk/components/camel-exec/src/main/java/org/apache/camel/component/exec/impl/ExecParseUtils.java]
and a link to the [unit tests|https://svn.apache.org/repos/asf/camel/trunk/components/camel-exec/src/test/java/org/apache/camel/component/exec/impl/ExecParseUtilsTest.java].


What do you think of this approach? Is it applicable to commons-exec?
 
Regards,
Mitko

      was (Author: mkolev):
    Hello everyone,
I am using the commons-exec library in Apache Camel (the command arguments must be parsed
from a URI), came up to the same problem, and had to implement the parsing myself. I did the
custom command line args parsing based on the following 3 simple rules: 

* The args in the line are space-separated tokens
* If an argument has a space itself, this space can be quoted with " (double-qoute)
* If an argument should preserve the double-quotes, it is quoted two times with a double-quote

Here is [a link to to the parser|https://svn.apache.org/repos/asf/camel/trunk/components/camel-exec/src/main/java/org/apache/camel/component/exec/impl/ExecParseUtils.java]
and a link to the [unit tests|https://svn.apache.org/repos/asf/camel/trunk/components/camel-exec/src/test/java/org/apache/camel/component/exec/impl/ExecParseUtilsTest.java].


What do you think of this solution? Is it applicable to commons-exec?
 
Regards,
Mitko
  
> CommandLine does not work with double quote or single quote correctly
> ---------------------------------------------------------------------
>
>                 Key: EXEC-36
>                 URL: https://issues.apache.org/jira/browse/EXEC-36
>             Project: Commons Exec
>          Issue Type: Bug
>    Affects Versions: 1.0
>         Environment: Ubuntu 704, JDK1.6
>            Reporter: Kai Hu
>            Assignee: Siegfried Goeschl
>            Priority: Critical
>
> Please review and run the following junit test, either apache ant or apache exec does
not handle the qoute in the arguments correctly.
>    @Test
>     public void shouldHandleTheDoubelQuote() throws Exception {
>         String commandline = "./script/jrake cruise:publish_installers "
>                 + "INSTALLER_VERSION=unstable_2_1 "
>                 + "INSTALLER_PATH=\"/var/lib/ cruise-agent/installers\" "
>                 + "INSTALLER_DOWNLOAD_SERVER='something'"
>                 + "WITHOUT_HELP_DOC=true";
>         CommandLine line = CommandLine.parse(commandline);
>         String[] args  = line.getArguments();
>         assertThat(args[0], is("cruise:publish_installers"));
>         assertThat(args[1], is("INSTALLER_VERSION=unstable_2_1"));
>         assertThat(args[2], is("INSTALLER_PATH=\"/var/lib/ cruise-agent/installers\""));
>         assertThat(args[3], is("INSTALLER_DOWNLOAD_SERVER='something'"));
>         assertThat(args[4], is("WITHOUT_HELP_DOC=true"));
>     }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message