hadoop-common-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ivan Mitic (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HADOOP-9660) [WINDOWS] Powershell / cmd parses -Dkey=value from command line as [-Dkey, value] which breaks GenericsOptionParser
Date Sat, 29 Jun 2013 22:02:20 GMT

    [ https://issues.apache.org/jira/browse/HADOOP-9660?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13696203#comment-13696203
] 

Ivan Mitic commented on HADOOP-9660:
------------------------------------

I did a bit of unittesting of my own of the patch, and things are looking fine. One aspect
I explicitly tested was having an equal sign in the value, since this is a legit scenario.
Given that I couldn’t think of a counter example where the patch does not work (other than
passing a value of –D what was already discussed), I am +1 on the proposal

I noticed one minor bug in the patch, the following line can throw IndexOutOfBoundsException:
{code}
      if (args[i].equals("-D")) {
        newArgs.add(args[i]);
        prop = args[++i];
{code}
Test case which catches it:
{code}
      args = new String[]{"-fs", "hdfs://somefs/", "-D"};
      expectedMap = Maps.newHashMap();
      assertDOptionParsing(args, expectedMap, expectedRemainingArgs);
{code}


Otherwise, +1

Thanks Enis!

                
> [WINDOWS] Powershell / cmd parses -Dkey=value from command line as [-Dkey, value] which
breaks GenericsOptionParser
> -------------------------------------------------------------------------------------------------------------------
>
>                 Key: HADOOP-9660
>                 URL: https://issues.apache.org/jira/browse/HADOOP-9660
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: scripts, util
>            Reporter: Enis Soztutar
>            Assignee: Enis Soztutar
>             Fix For: 3.0.0, 2.1.0-beta
>
>         Attachments: hadoop-9660-branch1_v1.patch, hadoop-9660-branch1_v2.patch, hadoop-9660-branch2_v1.patch,
hadoop-9660-branch2_v2.patch
>
>
> When parsing parameters to a class implementing Tool, and using ToolRunner, we can pass

> {code}
> bin/hadoop <tool_class> -Dkey=value 
> {code}
> However, powershell parses the '=' sign itself, and sends it to  java as ["-Dkey", "value"]
which breaks GenericOptionsParser. 
> Using "-Dkey=value" or '-Dkey=value' does not fix the problem. The only workaround seems
to trick PS by using: 
> '"-Dkey=value"' (single + double quote)
> In cmd, "-Dkey=value" works, but not '"-Dkey=value"'. 
> http://stackoverflow.com/questions/4940375/how-do-i-pass-an-equal-sign-when-calling-a-batch-script-in-powershell

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message