summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-11-12 21:22:09 +0100
committerLeah Neukirchen <leah@vuxu.org>2017-11-12 21:22:09 +0100
commit589243c74c93bef948dfdd2dc3613041c58b6918 (patch)
tree98a1c974c467f12422cad5f02b3bb8e2eac8d84d
parent6d84edf84c184db1ef01243320441f7111ffb548 (diff)
downloadlr-589243c74c93bef948dfdd2dc3613041c58b6918.tar.gz
lr-589243c74c93bef948dfdd2dc3613041c58b6918.tar.xz
lr-589243c74c93bef948dfdd2dc3613041c58b6918.zip
add action 'skip' which is always false
-rw-r--r--NEWS.md3
-rw-r--r--README.md1
-rw-r--r--lr.11
-rw-r--r--lr.c5
4 files changed, 10 insertions, 0 deletions
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`.
 	             | <modetest>
 	             | prune             -- do not traverse into subdirectories
 	             | print             -- always true value
+	             | skip              -- always true value
 	             | color <num>       -- always true value, override 256-color
 
         <timeprop> ::= 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:
              | <modetest>
              | prune             -- do not traverse into subdirectories
              | print             -- always true value
+             | skip              -- always false value
              | color <num>       -- always true value, override 256-color
 
 <timeprop> ::= 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;