Mercurial > hg > toybox
changeset 570:83702597fd31
Require -R to recurse, but descend into directories listed on command line.
author | Rob Landley <rob@landley.net> |
---|---|
date | Tue, 24 Apr 2012 05:48:03 -0500 |
parents | 2e0367cb9585 |
children | 1a06fcaa1775 |
files | toys/ls.c |
diffstat | 1 files changed, 3 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/toys/ls.c Sun Apr 22 23:01:23 2012 -0500 +++ b/toys/ls.c Tue Apr 24 05:48:03 2012 -0500 @@ -157,7 +157,8 @@ 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 @@ // 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);