aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-04-24 05:48:03 -0500
committerRob Landley <rob@landley.net>2012-04-24 05:48:03 -0500
commit5c4ac67899a4c75cfda7137436b6ce1885b36077 (patch)
tree7079ce86271e1fe5b2e04efcdb2543271740493c
parent9b3af46b888a57c2183545455e2de1cb457d9f2a (diff)
downloadtoybox-5c4ac67899a4c75cfda7137436b6ce1885b36077.tar.gz
Require -R to recurse, but descend into directories listed on command line.
-rw-r--r--toys/ls.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/toys/ls.c b/toys/ls.c
index 65cad79e..ff7567eb 100644
--- a/toys/ls.c
+++ b/toys/ls.c
@@ -157,7 +157,8 @@ static void listfiles(struct dirtree *indir)
int showdirs = 1;
// Figure out if we should show directories and current directory name
- if (indir == TT.files) showdirs = (flags & (FLAG_d|FLAG_R));
+ if (indir == TT.files)
+ showdirs = (flags & (FLAG_d|FLAG_R)) || indir->parent;
if (indir != TT.files || (indir->parent && (flags & FLAG_R))) {
char *path = dirtree_path(indir, 0);
@@ -272,7 +273,7 @@ static void listfiles(struct dirtree *indir)
// TODO follow symlinks when?
if (!S_ISDIR(sort[ul]->st.st_mode) || dirtree_isdotdot(sort[ul]))
continue;
- if (indir == TT.files || (flags & FLAG_R)) {
+ if (!indir->parent || (flags & FLAG_R)) {
int fd = openat(indir->data, sort[ul]->name, 0);
sort[ul]->data = dup(fd);