mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
Remove clap for echo (#7603)
* Parsing echo flags manually without clap as clap introduced various problematic interactions with hyphens * fixed error where multiple flags would parse wrong * Spelling & formatting fixes * docu for EchoFlag struct * more extensive comment/documentation * revert POSIXLY_CORRECT check to only check if it is set * Fixed problem of overwriting flags. Added test for same issue * cargo fmt * cspell * Update src/uu/echo/src/echo.rs Enabling POSIXLY_CORRECT flag if value is not UTF-8 Co-authored-by: Jan Verbeek <jan.verbeek@posteo.nl> --------- Co-authored-by: Jan Verbeek <jan.verbeek@posteo.nl>
This commit is contained in:
parent
99ca58a7ca
commit
13c0a813eb
2 changed files with 183 additions and 37 deletions
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
// spell-checker:ignore (words) araba merci mright
|
||||
// spell-checker:ignore (words) araba merci efjkow
|
||||
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
|
@ -126,6 +126,16 @@ fn test_escape_override() {
|
|||
.args(&["-E", "-e", "\\na"])
|
||||
.succeeds()
|
||||
.stdout_only("\na\n");
|
||||
|
||||
new_ucmd!()
|
||||
.args(&["-E", "-e", "-n", "\\na"])
|
||||
.succeeds()
|
||||
.stdout_only("\na");
|
||||
|
||||
new_ucmd!()
|
||||
.args(&["-e", "-E", "-n", "\\na"])
|
||||
.succeeds()
|
||||
.stdout_only("\\na");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -276,6 +286,89 @@ fn test_double_hyphens_at_start() {
|
|||
.stdout_only("-- a b --\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_double_hyphens_after_single_hyphen() {
|
||||
new_ucmd!()
|
||||
.arg("-")
|
||||
.arg("--")
|
||||
.succeeds()
|
||||
.stdout_only("- --\n");
|
||||
|
||||
new_ucmd!()
|
||||
.arg("-")
|
||||
.arg("-n")
|
||||
.arg("--")
|
||||
.succeeds()
|
||||
.stdout_only("- -n --\n");
|
||||
|
||||
new_ucmd!()
|
||||
.arg("-n")
|
||||
.arg("-")
|
||||
.arg("--")
|
||||
.succeeds()
|
||||
.stdout_only("- --");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_flag_like_arguments_which_are_no_flags() {
|
||||
new_ucmd!()
|
||||
.arg("-efjkow")
|
||||
.arg("--")
|
||||
.succeeds()
|
||||
.stdout_only("-efjkow --\n");
|
||||
|
||||
new_ucmd!()
|
||||
.arg("--")
|
||||
.arg("-efjkow")
|
||||
.succeeds()
|
||||
.stdout_only("-- -efjkow\n");
|
||||
|
||||
new_ucmd!()
|
||||
.arg("-efjkow")
|
||||
.arg("-n")
|
||||
.arg("--")
|
||||
.succeeds()
|
||||
.stdout_only("-efjkow -n --\n");
|
||||
|
||||
new_ucmd!()
|
||||
.arg("-n")
|
||||
.arg("--")
|
||||
.arg("-efjkow")
|
||||
.succeeds()
|
||||
.stdout_only("-- -efjkow");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_backslash_n_last_char_in_last_argument() {
|
||||
new_ucmd!()
|
||||
.arg("-n")
|
||||
.arg("-e")
|
||||
.arg("--")
|
||||
.arg("foo\n")
|
||||
.succeeds()
|
||||
.stdout_only("-- foo\n");
|
||||
|
||||
new_ucmd!()
|
||||
.arg("-e")
|
||||
.arg("--")
|
||||
.arg("foo\\n")
|
||||
.succeeds()
|
||||
.stdout_only("-- foo\n\n");
|
||||
|
||||
new_ucmd!()
|
||||
.arg("-n")
|
||||
.arg("--")
|
||||
.arg("foo\n")
|
||||
.succeeds()
|
||||
.stdout_only("-- foo\n");
|
||||
|
||||
new_ucmd!()
|
||||
.arg("--")
|
||||
.arg("foo\n")
|
||||
.succeeds()
|
||||
.stdout_only("-- foo\n\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_double_hyphens_after_flags() {
|
||||
new_ucmd!()
|
||||
|
@ -292,6 +385,18 @@ fn test_double_hyphens_after_flags() {
|
|||
.succeeds()
|
||||
.stdout_only("-- foo\n");
|
||||
|
||||
new_ucmd!()
|
||||
.arg("-ne")
|
||||
.arg("--")
|
||||
.succeeds()
|
||||
.stdout_only("--");
|
||||
|
||||
new_ucmd!()
|
||||
.arg("-neE")
|
||||
.arg("--")
|
||||
.succeeds()
|
||||
.stdout_only("--");
|
||||
|
||||
new_ucmd!()
|
||||
.arg("-e")
|
||||
.arg("--")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue