[PATCH 2/5] ls: don't print . and .. on recursive ls

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



They are already omitted on normal ls and they don't really add a new
information, so drop them for the recursive case as well.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 commands/ls.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/commands/ls.c b/commands/ls.c
index 6a5475d094e5..59163f678d51 100644
--- a/commands/ls.c
+++ b/commands/ls.c
@@ -75,8 +75,13 @@ int ls(const char *path, ulong flags)
 	if (!dir)
 		return -errno;
 
-	while ((d = readdir(dir)))
+	while ((d = readdir(dir))) {
+		if (!strcmp(d->d_name, "."))
+			continue;
+		if (!strcmp(d->d_name, ".."))
+			continue;
 		string_list_add_sorted(&sl, d->d_name);
+	}
 
 	closedir(dir);
 
@@ -99,10 +104,6 @@ int ls(const char *path, ulong flags)
 		goto out;
 
 	string_list_for_each_entry(entry, &sl) {
-		if (!strcmp(entry->str, "."))
-			continue;
-		if (!strcmp(entry->str, ".."))
-			continue;
 		sprintf(tmp, "%s/%s", path, entry->str);
 
 		ret = lstat(tmp, &s);
-- 
2.28.0


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux