From 589243c74c93bef948dfdd2dc3613041c58b6918 Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Sun, 12 Nov 2017 21:22:09 +0100 Subject: add action 'skip' which is always false --- NEWS.md | 3 +++ README.md | 1 + lr.1 | 1 + lr.c | 5 +++++ 4 files changed, 10 insertions(+) diff --git a/NEWS.md b/NEWS.md index 6b2968e..7732c35 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,9 @@ * Feature: new option `-B` for breadth first traversal. * Feature: new syntax `? :` for ternary operator. +* Feature: new action `skip` which is always false. + The common find(1) idiom `-name x -prune -o -print` + is now best written as `name = "x" ? prune && skip : print`. * Significant speed-up as tsearch is not used anymore. ## 1.1 (2017-10-29) diff --git a/README.md b/README.md index eb21a3c..643e9bf 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,7 @@ Default: `n`. | | prune -- do not traverse into subdirectories | print -- always true value + | skip -- always true value | color -- always true value, override 256-color ::= atime | ctime | mtime diff --git a/lr.1 b/lr.1 index a51a95b..fac5493 100644 --- a/lr.1 +++ b/lr.1 @@ -295,6 +295,7 @@ tests are given by the following EBNF: | | prune -- do not traverse into subdirectories | print -- always true value + | skip -- always false value | color -- always true value, override 256-color ::= atime | ctime | mtime diff --git a/lr.c b/lr.c index 87aefb4..08d849f 100644 --- a/lr.c +++ b/lr.c @@ -417,6 +417,11 @@ parse_inner() } else if (token("print")) { struct expr *e = mkexpr(EXPR_PRINT); return e; + } else if (token("skip")) { + struct expr *e = mkexpr(EXPR_PRINT); + struct expr *not = mkexpr(EXPR_NOT); + not->a.expr = e; + return not; } else if (token("color")) { struct expr *e = mkexpr(EXPR_COLOR); int64_t n; -- cgit 1.4.1