diff options
author | Rob Landley <rob@landley.net> | 2015-05-18 13:33:36 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2015-05-18 13:33:36 -0500 |
commit | a8ee470ae3361bb8e6e364f0e8adf61259371e95 (patch) | |
tree | 07c7a1de0d5c1382362cae92f5c120311eeee411 /toys/posix | |
parent | c565b06325960a16ebf44afd8ae73f363775e58d (diff) | |
download | toybox-a8ee470ae3361bb8e6e364f0e8adf61259371e95.tar.gz |
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).
Diffstat (limited to 'toys/posix')
-rw-r--r-- | toys/posix/ls.c | 5 |
1 files changed, 3 insertions, 2 deletions
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); |