[git commit] grep: make errors other than "not found" result in exit code 2. Closes 8796

Denys Vlasenko vda.linux at googlemail.com
Mon Mar 28 20:12:09 UTC 2016


commit: https://git.busybox.net/busybox/commit/?id=73dfdda92e20da718a9cb398ed762cc09c82e3a7
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 findutils/grep.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/findutils/grep.c b/findutils/grep.c
index 10b6927..dece90c 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -681,11 +681,15 @@ int grep_main(int argc UNUSED_PARAM, char **argv)
 	FILE *file;
 	int matched;
 	llist_t *fopt = NULL;
-
-	/* do normal option parsing */
 #if ENABLE_FEATURE_GREP_CONTEXT
 	int Copt, opts;
+#endif
 
+	/* For grep, exitcode of 1 is "not found". Other errors are 2: */
+	xfunc_error_retval = 2;
+
+	/* do normal option parsing */
+#if ENABLE_FEATURE_GREP_CONTEXT
 	/* -H unsets -h; -C unsets -A,-B; -e,-f are lists;
 	 * -m,-A,-B,-C have numeric param */
 	opt_complementary = "H-h:C-AB:e::f::m+:A+:B+:C+";


More information about the busybox-cvs mailing list