mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +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:
parent
606c1badd2
commit
0d0087053f
1 changed files with 13 additions and 7 deletions
20
src/ls/ls.rs
20
src/ls/ls.rs
|
@ -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()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue