This project is read-only.

Bug in quotation marks handling


program.exe -s "-somedata"

This will fail due to the hyphen following the quotation mark. The hyphen is somehow mistaken as being a part of the command line switches.

Temporary fix is to put a space in between the quotation mark and the hyphen.


Marcel81 wrote Sep 22, 2015 at 9:07 PM

Sad that this has not been fixed when there's no other stable version available. Only 2.x pre versions.

wrote Sep 22, 2015 at 9:07 PM

wrote Nov 18, 2015 at 8:45 PM

cm1 wrote Nov 26, 2015 at 5:41 PM

The code assumes that any string that begins with a '-' is an argument to CommandParser itself. The logic which causes this error is in ArgumentParser.cs, here:
    public static bool IsInputValue(string argument)
        if (argument.IsNumeric())
            return true;

        if (argument.Length > 0)
            return IsDash(argument) || !IsShortOption(argument);

        return true;
, which is called by this code in OptionGroupParser.cs here:

public override PresentParserState Parse(IArgumentEnumerator argumentEnumerator, OptionMap map, object options)
                if (!argumentEnumerator.IsLast && !ArgumentParser.IsInputValue(argumentEnumerator.Next))
                    return PresentParserState.Failure;
I would like this fixed because I am using CommandParser in an ExeWrapper, an application which itself invokes another .exe. As such have I specified the options “-x” (for the name of the .exe to invoke) and “-a” (for the args to pass to that exe). The args often begin with the character “-“. My command line is thus:

-x “myexe.exe” -a “-i”

Thank you for the workaround suggestion!

wrote Nov 26, 2015 at 5:42 PM

wrote Feb 8, 2016 at 5:53 AM