Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

env attempts to parse options in the command #14

Closed
jaraco opened this issue Dec 20, 2023 · 1 comment
Closed

env attempts to parse options in the command #14

jaraco opened this issue Dec 20, 2023 · 1 comment

Comments

@jaraco
Copy link
Owner

jaraco commented Dec 20, 2023

Consider this invocation:

 @ env PYTHONPATH=devtools/py py -m switch-track --help
usage: env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]

Set each NAME to VALUE in the environment and run COMMAND.

positional arguments:
  inputs

options:
  -h, --help            show this help message and exit
  -i, --ignore-environment
                        start with an empty environment

or

 @ env PYTHONPATH=devtools/py py -m switch-track
usage: env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]
env: error: unrecognized arguments: -m switch-track

The arg parsing is failing because the -m and --help are being parsed for env. env needs to ignore any options after the first argument is encountered.

@jaraco
Copy link
Owner Author

jaraco commented Dec 20, 2023

I notice the [-] in the usage. However, injecting a - ahead of the command seems to have no effect. I did find, by checking the argparse docs, that injecting -- ahead of the command args does force them to be passed through to the subprocess command.

That option isn't available on env for macOS, but I do see it on Linux, where:

A mere - implies -i.

Probably cmdix should mimic that behavior for compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant