Skip to content

Error parsing command arguments #200

Open

Description

@sestrella

I got the following error passing a "command" as an argument to yesod devel:

> dotenv -o -- yesod devel --success-hook "echo foo"
Invalid argument `foo'

Usage: yesod [-d|--dev] [-v|--verbose] COMMAND

If I call it directly, it works as expected:

> yesod devel --success-hook "echo foo"

My theory is that this is not related to yesod devel per se, but rather to how dotenv -- <command> <args> works, as it seems that is not properly escaping the arguments after --

Activity

  1. aloussase commented on Nov 8, 2024

    @aloussase
    Contributor

    I can reproduce the bug with the following example:

    image

    (don't mind the dot at the end)

    And adding some debug logging I see:

    image

    Which shows that arguments after -- don't seem to keep the quotes. The parser for the arguments looks like this:

    many (argument str (metavar "ARG"))

    Which seems correct and makes me think this might be a bug in optparse-applicative?

    This is the result of getArgs:

    image

    I think maybe the individual elements of the list are not being quoted, which causes the parser to interpret "echo hi" as 2 separate arguments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions