1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 03:57:44 +00:00

ls: Fix '-aR' recursion.

ls with -aR was recursing infinitely becacuse it
added ./.. to every node. I don't see a way to
avoid this except by cloning when that option
is used.
This commit is contained in:
Zephiris 2016-11-05 01:29:55 -07:00
parent 606c1badd2
commit 0d0087053f

View file

@ -236,15 +236,21 @@ fn enter_directory(dir: &PathBuf, options: &getopts::Matches) {
}
let mut entries: Vec<_> = entries.iter().map(DirEntry::path).collect();
if options.opt_present("a") {
entries.push(dir.join("."));
entries.push(dir.join(".."));
}
sort_entries(&mut entries, options);
display_items(&entries, Some(dir), options);
if options.opt_present("a") {
let mut display_entries = entries.clone();
display_entries.insert(0, dir.join(".."));
display_entries.insert(0, dir.join("."));
display_items(&display_entries, Some(dir), options);
}
else
{
display_items(&entries, Some(dir), options);
}
if options.opt_present("R") {
for e in entries.iter().filter(|p| p.is_dir()) {