diff options
author | Leah Neukirchen <leah@vuxu.org> | 2019-03-15 12:20:00 +0100 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2019-03-15 12:20:00 +0100 |
commit | 7ff5e319a9f022445944bdb17ebc7941412ca3f9 (patch) | |
tree | 133f31da2f0345fcf1ada4d89d19025f7d077fab | |
parent | b8b156a54e9b94774e07c90081308a784fef84ab (diff) | |
download | lr-7ff5e319a9f022445944bdb17ebc7941412ca3f9.tar.gz lr-7ff5e319a9f022445944bdb17ebc7941412ca3f9.tar.xz lr-7ff5e319a9f022445944bdb17ebc7941412ca3f9.zip |
define a hidden color and use it for -B so traversal can continue
-rw-r--r-- | lr.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/lr.c b/lr.c index 4dcd7f2..8ecb295 100644 --- a/lr.c +++ b/lr.c @@ -97,6 +97,9 @@ static int sflag; static int xflag; static char Tflag = 'T'; +#define COLOR_DEFAULT -1 +#define COLOR_HIDDEN -2 + static char *argv0; static char *format; static char *ordering; @@ -1866,7 +1869,7 @@ color_name_on(int c, const char *f, mode_t m) if (!Gflag) return; - if (c != -1) { + if (c != COLOR_DEFAULT) { fg256(c); return; } @@ -1924,6 +1927,10 @@ print_format(struct fileinfo *fi) { int c, v; char *s; + + if (fi->color == COLOR_HIDDEN) + return; + for (s = format; *s; s++) { if (*s == '\\') { switch (*++s) { @@ -2138,9 +2145,14 @@ callback(const char *fpath, const struct stat *sb, int depth, ino_t entries, off fi->color = current_color; memcpy((char *)&fi->sb, (char *)sb, sizeof (struct stat)); + prune = 0; if (expr && !eval(expr, fi)) { - free_fi(fi); - return 0; + if (Bflag && !prune) { + fi->color = COLOR_HIDDEN; + } else { + free_fi(fi); + return 0; + } } if (need_xattr) { @@ -2258,7 +2270,6 @@ recurse(char *path, struct history *h, int guessdir) entries = 0; if (!Dflag) { - prune = 0; r = callback(path, &st, new.level, 0, 0); if (prune) return 0; @@ -2513,7 +2524,7 @@ main(int argc, char *argv[]) } } - current_color = -1; + current_color = COLOR_DEFAULT; initial = 1; if (!Cflag && optind == argc) { |