[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [PATCH] Improve support for long options to grep
From:       Walter Lozano <walter.lozano () collabora ! com>
Date:       2022-01-24 14:48:01
Message-ID: 20220124144801.760099-1-walter.lozano () collabora ! com
[Download RAW message or body]

In order to improve compatibility with GNU grep improve support for long
options to busybox grep.

Signed-off-by: Walter Lozano <walter.lozano@collabora.com>
---
 findutils/grep.c | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/findutils/grep.c b/findutils/grep.c
index 0b72812f1..2cc47df00 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -720,12 +720,40 @@ int grep_main(int argc UNUSED_PARAM, char **argv)
 
 	/* do normal option parsing */
 #if ENABLE_FEATURE_GREP_CONTEXT
+	static const char grep_longopts[] ALIGN1 =
+		"with-filename\0"        No_argument         "H"
+		"no-filename\0"          No_argument         "h"
+		"line-number\0"          No_argument         "n"
+		"files-without-match\0"  No_argument         "L"
+		"files-with-matches\0"   No_argument         "l"
+		"count\0"                No_argument         "c"
+		"only-matching\0"        No_argument         "o"
+		"quiet\0"                No_argument         "q"
+		"silent\0"               No_argument         "q"
+		"invert-match\0"         No_argument         "v"
+		"no-messages\0"          No_argument         "s"
+		"recursive\0"            No_argument         "r"
+		"ignore-case\0"          No_argument         "i"
+		"word-regexp\0"          No_argument         "w"
+		"line-regexp\0"          No_argument         "x"
+		"fixed-strings\0"        No_argument         "F"
+		"extended-regexp\0"      No_argument         "E"
+		"null-data\0"            No_argument         "z"
+		"max-count\0"            Required_argument   "m"
+		"after-context\0"        Required_argument   "A"
+		"before-context\0"       Required_argument   "B"
+		"context\0"              Required_argument   "C"
+		"regexp\0"               Required_argument   "e"
+		"file\0"                 Required_argument   "f"
+		"color\0"                Optional_argument   "\xff"
+		;
+
 	/* -H unsets -h; -C unsets -A,-B */
 	opts = getopt32long(argv, "^"
 		OPTSTR_GREP
 			"\0"
 			"H-h:C-AB",
-		"color\0" Optional_argument "\xff",
+		grep_longopts,
 		&pattern_head, &fopt, &max_matches,
 		&lines_after, &lines_before, &Copt
 		, NULL
-- 
2.30.2

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic