mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
Merge pull request #7781 from dan-hipschman/env-ignore-flags-after-command
env: ignore flags after the command or -- argument
This commit is contained in:
commit
1d89ea5b6d
2 changed files with 120 additions and 22 deletions
|
@ -66,6 +66,61 @@ fn test_invalid_arg() {
|
|||
new_ucmd!().arg("--definitely-invalid").fails_with_code(125);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
fn test_flags_after_command() {
|
||||
new_ucmd!()
|
||||
// This would cause an error if -u=v were processed because it's malformed
|
||||
.args(&["echo", "-u=v"])
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_is("-u=v\n");
|
||||
|
||||
new_ucmd!()
|
||||
// Ensure the string isn't split
|
||||
// cSpell:disable
|
||||
.args(&["printf", "%s-%s", "-Sfoo bar"])
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_is("-Sfoo bar-");
|
||||
// cSpell:enable
|
||||
|
||||
new_ucmd!()
|
||||
// Ensure -- is recognized
|
||||
.args(&["-i", "--", "-u=v"])
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_is("-u=v\n");
|
||||
|
||||
new_ucmd!()
|
||||
// Recognize echo as the command after a flag that takes a value
|
||||
.args(&["-C", "..", "echo", "-u=v"])
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_is("-u=v\n");
|
||||
|
||||
new_ucmd!()
|
||||
// Recognize echo as the command after a flag that takes an inline value
|
||||
.args(&["-C..", "echo", "-u=v"])
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_is("-u=v\n");
|
||||
|
||||
new_ucmd!()
|
||||
// Recognize echo as the command after a flag that takes a value after another flag
|
||||
.args(&["-iC", "..", "echo", "-u=v"])
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_is("-u=v\n");
|
||||
|
||||
new_ucmd!()
|
||||
// Similar to the last two combined
|
||||
.args(&["-iC..", "echo", "-u=v"])
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_is("-u=v\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_env_help() {
|
||||
new_ucmd!()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue