1
Fork 0
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:
Dorian Péron 2024-05-14 00:49:12 +02:00
parent 147c0b6962
commit 105024e708
2 changed files with 16 additions and 3 deletions

View file

@ -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()

View file

@ -2961,6 +2961,7 @@ fn test_ls_align_unquoted() {
at.touch("'quoted'");
// In TTY
#[cfg(unix)]
scene
.ucmd()
.arg("--color")