mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-31 04:57:45 +00:00
Merge pull request #3615 from anastygnome/fork
ls: Remove unnecessary trailing space when using the comma format (-m)
This commit is contained in:
commit
045c047d20
2 changed files with 30 additions and 1 deletions
|
@ -1874,7 +1874,12 @@ fn display_additional_leading_info(
|
||||||
} else {
|
} else {
|
||||||
"?".to_owned()
|
"?".to_owned()
|
||||||
};
|
};
|
||||||
write!(result, "{} ", pad_left(&s, padding.block_size)).unwrap();
|
// extra space is insert to align the sizes, as needed for all formats, except for the comma format.
|
||||||
|
if config.format == Format::Commas {
|
||||||
|
write!(result, "{} ", s).unwrap();
|
||||||
|
} else {
|
||||||
|
write!(result, "{} ", pad_left(&s, padding.block_size)).unwrap();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
|
@ -803,6 +803,30 @@ fn test_ls_commas() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_ls_commas_trailing() {
|
||||||
|
let scene = TestScenario::new(util_name!());
|
||||||
|
let at = &scene.fixtures;
|
||||||
|
at.touch(&at.plus_as_string("test-commas-trailing-2"));
|
||||||
|
|
||||||
|
at.touch(&at.plus_as_string("test-commas-trailing-1"));
|
||||||
|
at.append(
|
||||||
|
"test-commas-trailing-1",
|
||||||
|
&(0..2000)
|
||||||
|
.map(|x| x.to_string())
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join("\n"),
|
||||||
|
);
|
||||||
|
|
||||||
|
scene
|
||||||
|
.ucmd()
|
||||||
|
.arg("-sm")
|
||||||
|
.arg("./test-commas-trailing-1")
|
||||||
|
.arg("./test-commas-trailing-2")
|
||||||
|
.succeeds()
|
||||||
|
.stdout_matches(&Regex::new(r"\S$").unwrap()); // matches if there is no whitespace at the end of stdout.
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_ls_long() {
|
fn test_ls_long() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let scene = TestScenario::new(util_name!());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue