mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/5] ls: don't print . and .. on recursive ls
Date: Mon, 14 Sep 2020 15:37:45 +0200	[thread overview]
Message-ID: <20200914133748.5988-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20200914133748.5988-1-a.fatoum@pengutronix.de>

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@pengutronix.de>
---
 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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2020-09-14 13:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-14 13:37 [PATCH 1/5] lib: string: retire deprecated strtok() in favor of reentrant strsep() Ahmad Fatoum
2020-09-14 13:37 ` Ahmad Fatoum [this message]
2020-09-14 13:37 ` [PATCH 3/5] sandbox: implement simple, ^C-interruptible, restart handler Ahmad Fatoum
2020-09-14 13:37 ` [PATCH 4/5] sandbox: implement actual sandbox reset via exec(2) Ahmad Fatoum
2020-09-15  5:21   ` [PATCH] fixup! " Ahmad Fatoum
2020-09-14 13:37 ` [PATCH 5/5] sandbox: hostfile: support registering images as barebox block devices Ahmad Fatoum
2020-09-15  7:26 ` [PATCH 1/5] lib: string: retire deprecated strtok() in favor of reentrant strsep() Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200914133748.5988-2-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox