mirror of
https://github.com/uutils/coreutils
synced 2024-11-17 02:08:09 +00:00
ls: Fix minor output mismatch
When a single directory is passed to ls in recursive mode, uutils ls won't print the directory name ====================== GNU ls: z: ====================== ====================== uutils ls: ====================== This commit fixes this minor inconsistency and adds corresponding test.
This commit is contained in:
parent
4d51e16140
commit
898d325aea
2 changed files with 7 additions and 1 deletions
|
@ -1223,7 +1223,7 @@ fn list(locs: Vec<String>, config: Config) -> i32 {
|
||||||
|
|
||||||
sort_entries(&mut dirs, &config);
|
sort_entries(&mut dirs, &config);
|
||||||
for dir in dirs {
|
for dir in dirs {
|
||||||
if locs.len() > 1 {
|
if locs.len() > 1 || config.recursive {
|
||||||
let _ = writeln!(out, "\n{}:", dir.p_buf.display());
|
let _ = writeln!(out, "\n{}:", dir.p_buf.display());
|
||||||
}
|
}
|
||||||
enter_directory(&dir, &config, &mut out);
|
enter_directory(&dir, &config, &mut out);
|
||||||
|
|
|
@ -899,6 +899,12 @@ fn test_ls_recursive() {
|
||||||
|
|
||||||
scene.ucmd().arg("a").succeeds();
|
scene.ucmd().arg("a").succeeds();
|
||||||
scene.ucmd().arg("a/a").succeeds();
|
scene.ucmd().arg("a/a").succeeds();
|
||||||
|
scene
|
||||||
|
.ucmd()
|
||||||
|
.arg("z")
|
||||||
|
.arg("-R")
|
||||||
|
.succeeds()
|
||||||
|
.stdout_contains(&"z:");
|
||||||
let result = scene
|
let result = scene
|
||||||
.ucmd()
|
.ucmd()
|
||||||
.arg("--color=never")
|
.arg("--color=never")
|
||||||
|
|
Loading…
Reference in a new issue