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. --- tests/find.test | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests/find.test') diff --git a/tests/find.test b/tests/find.test index de48c5c8..6b0b0a8a 100755 --- a/tests/find.test +++ b/tests/find.test @@ -56,6 +56,10 @@ testing "-type f -user -exec" \ "find dir -type f -user $USER -exec ls {} \\;" "dir/file\n" "" "" testing "-type l -newer -exec" \ "find dir -type l -newer dir/file -exec ls {} \\;" "dir/link\n" "" "" +testing "-exec true \\; -print" \ + "find dir/file -exec true \\; -print" "dir/file\n" "" "" +testing "-exec false \\; -print" \ + "find dir/file -exec false \\; -print" "" "" "" testing "-perm (exact success)" \ "find perm -type f -perm 0444" "perm/all-read-only\n" "" "" testing "-perm (exact failure)" \ -- cgit v1.2.3