mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +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 {
|
||||
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
|
||||
.map(|n| {
|
||||
if n.starts_with('\'') {
|
||||
format!(" {n}")
|
||||
} else {
|
||||
if n.starts_with('\'') || n.starts_with('"') {
|
||||
n
|
||||
} else {
|
||||
format!(" {n}")
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
|
|
|
@ -2961,6 +2961,7 @@ fn test_ls_align_unquoted() {
|
|||
at.touch("'quoted'");
|
||||
|
||||
// In TTY
|
||||
#[cfg(unix)]
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("--color")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue