From a8ee470ae3361bb8e6e364f0e8adf61259371e95 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 18 May 2015 13:33:36 -0500 Subject: Recent commit broke ls -R (test reversed), and "ls -R singledir" should show label: at the start (yes, even "ls -R" in an empty dir). --- toys/posix/ls.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'toys/posix/ls.c') diff --git a/toys/posix/ls.c b/toys/posix/ls.c index ae0466bf..c140d979 100644 --- a/toys/posix/ls.c +++ b/toys/posix/ls.c @@ -289,7 +289,7 @@ static void listfiles(int dirfd, struct dirtree *indir) // Silently descend into single directory listed by itself on command line. // In this case only show dirname/total header when given -R. dt = indir->child; - if (S_ISDIR(dt->st.st_mode) && !dt->next && !(flags & FLAG_d)) { + if (S_ISDIR(dt->st.st_mode) && !dt->next && !(flags&(FLAG_d|FLAG_R))) { listfiles(open(dt->name, 0), TT.singledir = dt); return; @@ -480,8 +480,9 @@ static void listfiles(int dirfd, struct dirtree *indir) if ((flags & FLAG_d) || !S_ISDIR(sort[ul]->st.st_mode)) continue; // Recurse into dirs if at top of the tree or given -R - if (!indir->parent || ((flags&FLAG_R) && !dirtree_notdotdot(sort[ul]))) + if (!indir->parent || ((flags&FLAG_R) && dirtree_notdotdot(sort[ul]))) listfiles(openat(dirfd, sort[ul]->name, 0), sort[ul]); + free((void *)sort[ul]->extra); } free(sort); if (dirfd != AT_FDCWD) close(dirfd); -- cgit v1.2.3