1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

ls: when -CF is passed, use a tab. closes: #5396

This commit is contained in:
Sylvestre Ledru 2024-07-02 23:32:49 +02:00
parent a18c132994
commit fd2c4a14b8
2 changed files with 13 additions and 5 deletions

View file

@ -2650,7 +2650,7 @@ fn display_grid(
writeln!(out)?; writeln!(out)?;
} }
} else { } else {
let names = if quoted { let names: Vec<String> = if quoted {
// In case some names are quoted, GNU adds a space before each // In case some names are quoted, GNU adds a space before each
// entry that does not start with a quote to make it prettier // entry that does not start with a quote to make it prettier
// on multiline. // on multiline.
@ -2675,12 +2675,21 @@ fn display_grid(
} else { } else {
names.collect() names.collect()
}; };
// Determine whether to use tabs for separation based on whether any entry ends with '/'.
// If any entry ends with '/', it indicates that the -F flag is likely used to classify directories.
let use_tabs = names.iter().any(|name| name.ends_with('/'));
let filling = if use_tabs {
Filling::Text("\t".to_string())
} else {
Filling::Spaces(2)
};
let grid = Grid::new( let grid = Grid::new(
names, names,
GridOptions { GridOptions {
// TODO: To match gnu/tests/ls/stat-dtype.sh filling,
// we might want to have Filling::Text("\t".to_string());
filling: Filling::Spaces(2),
direction, direction,
width: width as usize, width: width as usize,
}, },

View file

@ -4259,7 +4259,6 @@ fn test_ls_subdired_complex() {
assert_eq!(dirnames, vec!["dir1", "dir1\\c2", "dir1\\d"]); assert_eq!(dirnames, vec!["dir1", "dir1\\c2", "dir1\\d"]);
} }
#[ignore = "issue #5396"]
#[test] #[test]
fn test_ls_cf_output_should_be_delimited_by_tab() { fn test_ls_cf_output_should_be_delimited_by_tab() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();