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

Signed-off-by: Walter Lozano <[email protected]>
---
 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
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to