From bcb9821e2496e341b0ab5ff6cfd00a620eb7d152 Mon Sep 17 00:00:00 2001 From: Thomas Queiroz Date: Sat, 21 May 2022 18:04:17 -0300 Subject: [PATCH] ls: take into account "." and ".." when sorting --- src/uu/ls/src/ls.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index c1c6cfab4..52a5a1145 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -1732,8 +1732,6 @@ fn enter_directory( }; // Convert those entries to the PathData struct - let mut vec_path_data = Vec::new(); - for raw_entry in read_dir { let dir_entry = match raw_entry { Ok(path) => path, @@ -1747,12 +1745,11 @@ fn enter_directory( if should_display(&dir_entry, config) { let entry_path_data = PathData::new(dir_entry.path(), Some(Ok(dir_entry)), None, config, false); - vec_path_data.push(entry_path_data); + entries.push(entry_path_data); }; } - sort_entries(&mut vec_path_data, config, out); - entries.append(&mut vec_path_data); + sort_entries(&mut entries, config, out); // Print total after any error display if config.format == Format::Long || config.alloc_size {