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

Fix shlexing of passthrough args. (cherrypick of #12547) #12551

Merged
merged 1 commit into from
Aug 12, 2021

Conversation

stuhood
Copy link
Member

@stuhood stuhood commented Aug 12, 2021

./pants run example.py -- -flag "some args" currently results in a different sys.argv for the process than ./example.py -flag "some args" would. This was because we were applying shlexing after the source/rank of an option had been discarded, which was too late to determine whether to shlex (flag/config/env values should be shlexed: passthrough arguments should not).

Move shell_str list shlexing into ListValueComponent such that it is skipped when a ListValueComponent is manually constructed for passthrough args.

One downside of this change is that list-value addition and subtraction will now apply to the shlexed tokens of a string, rather than to the entire string (i.e +["some args"],-["args"] will result in a final set of ["some"]). But I expect that list subtraction is rare for shell_str args.

[ci skip-rust]
[ci skip-build-wheels]

`./pants run example.py -- -flag "some args"` currently results in a different `sys.argv` for the process than `./example.py -flag "some args"` would. This was because we were applying shlexing after the source/rank of an option had been discarded, which was too late to determine whether to shlex (flag/config/env values should be shlexed: passthrough arguments should not).

Move `shell_str` `list` shlexing into `ListValueComponent` such that it is skipped when a `ListValueComponent` is manually constructed for passthrough args.

One downside of this change is that list-value addition and subtraction will now apply to the shlexed tokens of a string, rather than to the entire string (i.e `+["some args"],-["args"]` will result in a final set of `["some"]`). But I expect that list subtraction is rare for `shell_str` args.

[ci skip-rust]
[ci skip-build-wheels]
@stuhood stuhood merged commit 2b6985e into pantsbuild:2.6.x Aug 12, 2021
@stuhood stuhood deleted the stuhood/pick-12547-for-2.6.x branch August 12, 2021 17:23
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

Successfully merging this pull request may close these issues.

2 participants