aboutsummaryrefslogtreecommitdiff
path: root/bpeg.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2020-09-16 21:34:55 -0700
committerBruce Hill <bruce@bruce-hill.com>2020-09-16 21:34:55 -0700
commit4f68ec87a20490662350c213baac26ea965f93b3 (patch)
tree638dc00a5e70e80b17718d12ad7b78d9109d28d3 /bpeg.c
parente7629990be8790a2d28e3a59dec71d05bb53b195 (diff)
Exit 1 iff *all* files fail to match instead of *any*
Diffstat (limited to 'bpeg.c')
-rw-r--r--bpeg.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/bpeg.c b/bpeg.c
index 8575ee3..c10be76 100644
--- a/bpeg.c
+++ b/bpeg.c
@@ -164,11 +164,11 @@ int main(int argc, char *argv[])
vm_op_t *pattern = lookup(g, rule);
check(pattern != NULL, "No such rule: '%s'", rule);
- int ret = 0;
+ int ret = 1;
if (i < argc) {
// Files pass in as command line args:
for (int nfiles = 0; i < argc; nfiles++, i++) {
- ret |= run_match(g, argv[i], pattern, flags);
+ ret &= run_match(g, argv[i], pattern, flags);
}
} else if (isatty(STDIN_FILENO)) {
// No files, no piped in input, so use * **/*:
@@ -176,12 +176,12 @@ int main(int argc, char *argv[])
glob("*", 0, NULL, &globbuf);
glob("**/*", GLOB_APPEND, NULL, &globbuf);
for (size_t i = 0; i < globbuf.gl_pathc; i++) {
- ret |= run_match(g, globbuf.gl_pathv[i], pattern, flags);
+ ret &= run_match(g, globbuf.gl_pathv[i], pattern, flags);
}
globfree(&globbuf);
} else {
// Piped in input:
- ret |= run_match(g, NULL, pattern, flags);
+ ret &= run_match(g, NULL, pattern, flags);
}