-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Correctly parse arguments from environment variables #14376
base: master
Are you sure you want to change the base?
Correctly parse arguments from environment variables #14376
Conversation
a1db1f6
to
ed6a168
Compare
output.extend( | ||
env_val | ||
.split_whitespace() | ||
Shlex::new(env_val) | ||
.into_iter() | ||
.map(|s| (s.to_string(), def.clone())), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need a test for this.
Ideally, the PR gets split up into two commits
- The first adds the test, showing the bad behavior
- This commit updates the test showing the good behavior
As discussed at https://doc.crates.io/contrib/process/working-on-cargo.html#submitting-a-pull-request
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted! Rewriting git history and using this occasion to add a test.
I'm unsure what the compatibility guarantees are around this. @ehuss if you have any insight, it'd be appreciated. In general, we recommend starting with an issue. That way we make sure we are all on the same page (e.g. the definition of the problem in this PR is unclear) and, if we go through multiple possible PRs for the problem (which is common enough), the conversation on the problem and solution space is centralized rather than split among all of the PRs. |
ed6a168
to
4b152ec
Compare
I opened #14381 too. |
let mut expected = Vec::new(); | ||
for sub in *value { | ||
expected.push(( | ||
sub.replace("\"", ""), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shlex
removes (double) quotes. Not sure whether or not it's a good thing. If it's not the expected behaviour, I can implement a simple shell parser which keeps them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocked on discussion in #14381
Fixes #14381.
The current parsing doesn't correctly handle arguments like
--x="y z"
. To be noted: if you don't want the dependency, I can write a parser by hand too, shouldn't take many lines of code to do.r? @epage