about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-11-12 21:19:48 +0100
committerLeah Neukirchen <leah@vuxu.org>2017-11-12 21:19:48 +0100
commit6d84edf84c184db1ef01243320441f7111ffb548 (patch)
tree99b8517a6eda6beb5fa50c8b403d422adf56e876
parent0720b6679e247224128f52e4a30e24513dad06b5 (diff)
downloadlr-6d84edf84c184db1ef01243320441f7111ffb548.tar.gz
lr-6d84edf84c184db1ef01243320441f7111ffb548.tar.xz
lr-6d84edf84c184db1ef01243320441f7111ffb548.zip
revert making prune be false
This makes things more confusing in the end (and is not how find(1)
works either).
-rw-r--r--NEWS.md3
-rw-r--r--lr.c4
2 files changed, 2 insertions, 5 deletions
diff --git a/NEWS.md b/NEWS.md
index c2b61f3..6b2968e 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,8 +1,5 @@
 ## HEAD
 
-* **Breaking change**: `prune` now evaluates to a false value.
-  The common find(1) idiom is now best written as `name = "x" ? prune : print`.
-
 * Feature: new option `-B` for breadth first traversal.
 * Feature: new syntax `? :` for ternary operator.
 * Significant speed-up as tsearch is not used anymore.
diff --git a/lr.c b/lr.c
index d5fff03..87aefb4 100644
--- a/lr.c
+++ b/lr.c
@@ -1273,7 +1273,7 @@ eval(struct expr *e, struct fileinfo *fi)
 		return !eval(e->a.expr, fi);
 	case EXPR_PRUNE:
 		prune = 1;
-		return 0;
+		return 1;
 	case EXPR_PRINT:
 		return 1;
 	case EXPR_COLOR:
@@ -2290,7 +2290,7 @@ main(int argc, char *argv[])
 	while ((c = getopt(argc, argv, "01ABC:DFGHLQST:UXde:f:lho:st:x")) != -1)
 		switch (c) {
 		case '0': format = zero_format; input_delim = 0; Qflag = 0; break;
-		case '1': expr = chain(parse_expr("depth > 0 && prune || print"), EXPR_AND, expr); break;
+		case '1': expr = chain(parse_expr("depth > 0 ? prune : print"), EXPR_AND, expr); break;
 		case 'A': expr = chain(expr, EXPR_AND, parse_expr("name =~ \"^\\.\" && path != \".\" ? prune : print")); break;
 		case 'B': Bflag++; Dflag = 0; Uflag = 0; need_stat++; break;
 		case 'C':