Skip to content

Quoted string starting with hyphen and space is interpreted as a flag (e.g. "- h") #2295

@GuySartorelli

Description

@GuySartorelli

If a quoted string starts with a hyphen and a space, the character following the space is interpreted as a flag. For example some-command '- http' is interpreted as some-command -h and shows help information for the command.

If FParseErrWhitelist.UnknownFlags is set to false, an error is displayed which implies the space is being interpreted as a flag as well:

Error: unknown shorthand flag: ' ' in - h

I don't think whitespace is a valid flag name so this seems like a bug to me. It can likely be avoided with a simple condition in the flag parsing:

  • For '- ', if unicode.IsSpace(rune(arg[1])), treat it as an argument
  • For '-- ', if unicode.IsSpace(rune(arg[2])), treat it as an argument

See ddev/ddev#7409 for additional context.
Related issue: #1733

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions