mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
ls: Fix --{show, hide}-control-chars logic
This commit is contained in:
parent
a93959aa44
commit
4d6faae555
2 changed files with 9 additions and 20 deletions
|
@ -428,11 +428,10 @@ impl Config {
|
||||||
#[allow(clippy::needless_bool)]
|
#[allow(clippy::needless_bool)]
|
||||||
let show_control = if options.is_present(options::HIDE_CONTROL_CHARS) {
|
let show_control = if options.is_present(options::HIDE_CONTROL_CHARS) {
|
||||||
false
|
false
|
||||||
} else if options.is_present(options::SHOW_CONTROL_CHARS) || atty::is(atty::Stream::Stdout)
|
} else if options.is_present(options::SHOW_CONTROL_CHARS) {
|
||||||
{
|
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
!atty::is(atty::Stream::Stdout)
|
||||||
};
|
};
|
||||||
|
|
||||||
let quoting_style = if let Some(style) = options.value_of(options::QUOTING_STYLE) {
|
let quoting_style = if let Some(style) = options.value_of(options::QUOTING_STYLE) {
|
||||||
|
|
|
@ -1416,6 +1416,7 @@ fn test_ls_quoting_style() {
|
||||||
// Default is shell-escape
|
// Default is shell-escape
|
||||||
scene
|
scene
|
||||||
.ucmd()
|
.ucmd()
|
||||||
|
.arg("--hide-control-chars")
|
||||||
.arg("one\ntwo")
|
.arg("one\ntwo")
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_only("'one'$'\\n''two'\n");
|
.stdout_only("'one'$'\\n''two'\n");
|
||||||
|
@ -1437,23 +1438,8 @@ fn test_ls_quoting_style() {
|
||||||
] {
|
] {
|
||||||
scene
|
scene
|
||||||
.ucmd()
|
.ucmd()
|
||||||
.arg(arg)
|
|
||||||
.arg("one\ntwo")
|
|
||||||
.succeeds()
|
|
||||||
.stdout_only(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'"),
|
|
||||||
] {
|
|
||||||
scene
|
|
||||||
.ucmd()
|
|
||||||
.arg(arg)
|
|
||||||
.arg("--hide-control-chars")
|
.arg("--hide-control-chars")
|
||||||
|
.arg(arg)
|
||||||
.arg("one\ntwo")
|
.arg("one\ntwo")
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_only(format!("{}\n", correct));
|
.stdout_only(format!("{}\n", correct));
|
||||||
|
@ -1463,7 +1449,7 @@ fn test_ls_quoting_style() {
|
||||||
("--quoting-style=literal", "one\ntwo"),
|
("--quoting-style=literal", "one\ntwo"),
|
||||||
("-N", "one\ntwo"),
|
("-N", "one\ntwo"),
|
||||||
("--literal", "one\ntwo"),
|
("--literal", "one\ntwo"),
|
||||||
("--quoting-style=shell", "one\ntwo"),
|
("--quoting-style=shell", "one\ntwo"), // FIXME: GNU ls quotes this case
|
||||||
("--quoting-style=shell-always", "'one\ntwo'"),
|
("--quoting-style=shell-always", "'one\ntwo'"),
|
||||||
] {
|
] {
|
||||||
scene
|
scene
|
||||||
|
@ -1490,6 +1476,7 @@ fn test_ls_quoting_style() {
|
||||||
] {
|
] {
|
||||||
scene
|
scene
|
||||||
.ucmd()
|
.ucmd()
|
||||||
|
.arg("--hide-control-chars")
|
||||||
.arg(arg)
|
.arg(arg)
|
||||||
.arg("one\\two")
|
.arg("one\\two")
|
||||||
.succeeds()
|
.succeeds()
|
||||||
|
@ -1505,6 +1492,7 @@ fn test_ls_quoting_style() {
|
||||||
] {
|
] {
|
||||||
scene
|
scene
|
||||||
.ucmd()
|
.ucmd()
|
||||||
|
.arg("--hide-control-chars")
|
||||||
.arg(arg)
|
.arg(arg)
|
||||||
.arg("one\n&two")
|
.arg("one\n&two")
|
||||||
.succeeds()
|
.succeeds()
|
||||||
|
@ -1535,6 +1523,7 @@ fn test_ls_quoting_style() {
|
||||||
] {
|
] {
|
||||||
scene
|
scene
|
||||||
.ucmd()
|
.ucmd()
|
||||||
|
.arg("--hide-control-chars")
|
||||||
.arg(arg)
|
.arg(arg)
|
||||||
.arg("one two")
|
.arg("one two")
|
||||||
.succeeds()
|
.succeeds()
|
||||||
|
@ -1558,6 +1547,7 @@ fn test_ls_quoting_style() {
|
||||||
] {
|
] {
|
||||||
scene
|
scene
|
||||||
.ucmd()
|
.ucmd()
|
||||||
|
.arg("--hide-control-chars")
|
||||||
.arg(arg)
|
.arg(arg)
|
||||||
.arg("one")
|
.arg("one")
|
||||||
.succeeds()
|
.succeeds()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue