mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +00:00
ls: Fix quoting alignment
This commit is contained in:
parent
147c0b6962
commit
105024e708
2 changed files with 16 additions and 3 deletions
|
@ -2616,12 +2616,24 @@ fn display_grid(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let names = if quoted {
|
let names = if quoted {
|
||||||
|
// In case some names are quoted, GNU adds a space before each
|
||||||
|
// entry that does not start with a quote to make it prettier
|
||||||
|
// on multiline.
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
// ```
|
||||||
|
// $ ls
|
||||||
|
// 'a\nb' bar
|
||||||
|
// foo baz
|
||||||
|
// ^ ^
|
||||||
|
// These spaces is added
|
||||||
|
// ```
|
||||||
names
|
names
|
||||||
.map(|n| {
|
.map(|n| {
|
||||||
if n.starts_with('\'') {
|
if n.starts_with('\'') || n.starts_with('"') {
|
||||||
format!(" {n}")
|
|
||||||
} else {
|
|
||||||
n
|
n
|
||||||
|
} else {
|
||||||
|
format!(" {n}")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
|
|
|
@ -2961,6 +2961,7 @@ fn test_ls_align_unquoted() {
|
||||||
at.touch("'quoted'");
|
at.touch("'quoted'");
|
||||||
|
|
||||||
// In TTY
|
// In TTY
|
||||||
|
#[cfg(unix)]
|
||||||
scene
|
scene
|
||||||
.ucmd()
|
.ucmd()
|
||||||
.arg("--color")
|
.arg("--color")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue