From 44dd6dd6520430b677ab97e886e8317490f04355 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Mon, 25 Mar 2019 14:44:58 -0700 Subject: find: fix inverted -exec exit status The return value of -exec was the command's exit code, which did not account for the fact that an exit code of zero means success, while in C, zero means failure. From POSIX: > the primary shall evaluate as true if the utility returns a zero > value as exit status This commit flips the return value, and adds two tests. --- toys/posix/find.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'toys/posix') diff --git a/toys/posix/find.c b/toys/posix/find.c index 1c35155b..5cefbf15 100644 --- a/toys/posix/find.c +++ b/toys/posix/find.c @@ -530,7 +530,7 @@ static int do_find(struct dirtree *new) aa->plus = 1; toys.exitval |= flush_exec(new, aa); } - } else test = flush_exec(new, aa); + } else test = !flush_exec(new, aa); } // Argument consumed, skip the check. -- cgit v1.2.3