1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 12:07:46 +00:00

Merge pull request #2016 from tertsdiepraam/ls/control_characters

ls: show/hide control chars
This commit is contained in:
Sylvestre Ledru 2021-04-04 18:38:15 +02:00 committed by GitHub
commit bd8b129d9a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 197 additions and 38 deletions

View file

@ -1142,9 +1142,9 @@ fn test_ls_quoting_style() {
assert_eq!(result.stdout, "'one'$'\\n''two'\n");
for (arg, correct) in &[
("--quoting-style=literal", "one\ntwo"),
("-N", "one\ntwo"),
("--literal", "one\ntwo"),
("--quoting-style=literal", "one?two"),
("-N", "one?two"),
("--literal", "one?two"),
("--quoting-style=c", "\"one\\ntwo\""),
("-Q", "\"one\\ntwo\""),
("--quote-name", "\"one\\ntwo\""),
@ -1161,6 +1161,42 @@ fn test_ls_quoting_style() {
println!("stdout = {:?}", result.stdout);
assert_eq!(result.stdout, format!("{}\n", correct));
}
for (arg, correct) in &[
("--quoting-style=literal", "one?two"),
("-N", "one?two"),
("--literal", "one?two"),
("--quoting-style=shell", "one?two"),
("--quoting-style=shell-always", "'one?two'"),
] {
let result = scene
.ucmd()
.arg(arg)
.arg("--hide-control-chars")
.arg("one\ntwo")
.run();
println!("stderr = {:?}", result.stderr);
println!("stdout = {:?}", result.stdout);
assert_eq!(result.stdout, format!("{}\n", correct));
}
for (arg, correct) in &[
("--quoting-style=literal", "one\ntwo"),
("-N", "one\ntwo"),
("--literal", "one\ntwo"),
("--quoting-style=shell", "one\ntwo"),
("--quoting-style=shell-always", "'one\ntwo'"),
] {
let result = scene
.ucmd()
.arg(arg)
.arg("--show-control-chars")
.arg("one\ntwo")
.run();
println!("stderr = {:?}", result.stderr);
println!("stdout = {:?}", result.stdout);
assert_eq!(result.stdout, format!("{}\n", correct));
}
}
let result = scene.ucmd().arg("one two").succeeds();