-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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: support string args by "-S", "-vS" or "--split-strings" #5801
env: support string args by "-S", "-vS" or "--split-strings" #5801
Conversation
I really don't like forking. Did you try to contact upstream to propose this behavior? Also, please squash your changes before you push them. Thanks |
I think the changes for |
3efb40a
to
52077cb
Compare
GNU testsuite comparison:
|
you forked this file, right ? |
yes. its content is partly in new file |
GNU testsuite comparison:
|
80a3291
to
d76ee6b
Compare
GNU testsuite comparison:
|
GNU testsuite comparison:
|
06d603a
to
a4a3ba1
Compare
GNU testsuite comparison:
|
84448b4
to
299decf
Compare
GNU testsuite comparison:
|
GNU testsuite comparison:
|
1 similar comment
GNU testsuite comparison:
|
GNU testsuite comparison:
|
b995a0d
to
c5eebe6
Compare
GNU testsuite comparison:
|
GNU testsuite comparison:
|
2 similar comments
GNU testsuite comparison:
|
GNU testsuite comparison:
|
GNU testsuite comparison:
|
514a489
to
ab50934
Compare
GNU testsuite comparison:
|
1 similar comment
GNU testsuite comparison:
|
ab5b5b8
to
b980a88
Compare
GNU testsuite comparison:
|
b980a88
to
2bd2e58
Compare
GNU testsuite comparison:
|
2bd2e58
to
7271b35
Compare
I implemented it now by using u8 byte arrays on linux and u16 word arrays on windows. |
GNU testsuite comparison:
|
is it ready for review ? :) |
7271b35
to
c62ba55
Compare
GNU testsuite comparison:
|
@sylvestre yes its ready. thanks |
} | ||
|
||
// NOTE: we manually set and unset the env vars below rather than using Command::env() to more | ||
// easily handle the case where no command is given | ||
#[allow(clippy::cognitive_complexity)] |
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.
for a future PR, it would be nice to address this warning
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.
this is moved code. But I'll address it anyway.
program: vec![], | ||
}; | ||
|
||
// change directory |
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.
explain the why :)
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.
this is moved code. But I'll address it anyway by extraction to function
// load .env-style config file prior to those given on the command-line | ||
load_config_file(&mut opts)?; | ||
|
||
// unset specified env vars |
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.
same, explain why we unset these variables.
Security?
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.
this is moved code. But I'll address it anyway by extraction to function.
the variables are unset because the corresponding command line argument to unset the variables is provided.
// `exit.code()` returns `None` on Unix when the process is terminated by a signal. | ||
// See std::os::unix::process::ExitStatusExt for more information. This prints out | ||
// the interrupted process and the signal it received. | ||
let signal_code = exit.signal().unwrap(); |
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.
should we handle the potential errors ? (same question for the next line)
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.
this is moved code.
I validated that the unwraps
are save. So I think there is nothing to address.
// For the full copyright and license information, please view the LICENSE | ||
// file that was distributed with this source code. | ||
|
||
// This module contains classes and functions for dealing with the differences |
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.
this can't be used elsewhere in the coreutils ?
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.
if so, maybe it could be moved into uucore
cc @cakebaker @tertsdiepraam
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.
I was planning to move it as soon as I found some other usecase for it.
But If you wish, I move it also in advance.
Some minor comments, it is impressive work btw :) |
given the size of the work, let's land it now and fix my comments later :) |
thanks. :-) |
its not related to "-S" as its in the env.sh.
if rust std-library allows to override this then it should be an easy thing. If not, it's difficult. |
addresses #5710
This implements all the functionality tested by gnu/tests/env/env-S.pl.
I had to patch the test due to more powerfull implementation and differencences in how parser errors are reported.
I Introduced a mechanism to patch the test with patch-files as the sed-stuff I could not make run for me.
The feature is quite complex, as the tool needs do parsing and evaluation (quoting, escape sequences, environmental variables) of the string on a similar level as a shell:
env -S<single full featured shell command>
I used "shell-words" create (MIT license) as a basis. I did heavy modifications, such that I directly commit the sources to this repo. EDIT: Additionally I extended shell-words with a variable expanstion functionality as needed by env.
The idea to use subst was rejected after discussions with the subst maintainer.