1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

echo: fixed double hyphen as argument (#7581)

* Fixes #7558 Added check to only insert addition double hyphen if at start of arguments to correctly prepend addition hyphens for clap as well as additional test case

* additional comment

* fixes issue where flags precedes "--" as arguments
This commit is contained in:
cerdelen 2025-03-28 13:31:48 +01:00 committed by GitHub
parent 1c75854d2f
commit 8c8beb96e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 121 additions and 6 deletions

View file

@ -242,6 +242,84 @@ fn test_hyphen_values_between() {
.stdout_is("dumdum dum dum dum -e dum\n");
}
#[test]
fn test_double_hyphens_at_start() {
new_ucmd!().arg("--").succeeds().stdout_only("--\n");
new_ucmd!()
.arg("--")
.arg("--")
.succeeds()
.stdout_only("-- --\n");
new_ucmd!()
.arg("--")
.arg("a")
.succeeds()
.stdout_only("-- a\n");
new_ucmd!()
.arg("--")
.arg("a")
.arg("b")
.succeeds()
.stdout_only("-- a b\n");
new_ucmd!()
.arg("--")
.arg("a")
.arg("b")
.arg("--")
.succeeds()
.stdout_only("-- a b --\n");
}
#[test]
fn test_double_hyphens_after_flags() {
new_ucmd!()
.arg("-e")
.arg("--")
.succeeds()
.stdout_only("--\n");
new_ucmd!()
.arg("-n")
.arg("-e")
.arg("--")
.arg("foo\n")
.succeeds()
.stdout_only("-- foo\n");
new_ucmd!()
.arg("-e")
.arg("--")
.arg("--")
.succeeds()
.stdout_only("-- --\n");
new_ucmd!()
.arg("-e")
.arg("--")
.arg("a")
.arg("--")
.succeeds()
.stdout_only("-- a --\n");
new_ucmd!()
.arg("-n")
.arg("--")
.arg("a")
.succeeds()
.stdout_only("-- a");
new_ucmd!()
.arg("-n")
.arg("--")
.arg("a")
.arg("--")
.succeeds()
.stdout_only("-- a --");
}
#[test]
fn test_double_hyphens() {
new_ucmd!().arg("--").succeeds().stdout_only("--\n");
@ -250,6 +328,29 @@ fn test_double_hyphens() {
.arg("--")
.succeeds()
.stdout_only("-- --\n");
new_ucmd!()
.arg("a")
.arg("--")
.arg("b")
.succeeds()
.stdout_only("a -- b\n");
new_ucmd!()
.arg("a")
.arg("--")
.arg("b")
.arg("--")
.succeeds()
.stdout_only("a -- b --\n");
new_ucmd!()
.arg("a")
.arg("b")
.arg("--")
.arg("--")
.succeeds()
.stdout_only("a b -- --\n");
}
#[test]