grep-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

grep branch, master, updated. v3.7-92-g6f52ef3


From: Paul Eggert
Subject: grep branch, master, updated. v3.7-92-g6f52ef3
Date: Mon, 6 Jun 2022 17:52:37 -0400 (EDT)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  6f52ef30e5634b1104b372c266ca8cc80b451c7d (commit)
      from  739892e8d4461a8246fa4c6a0ece18a14ce1e51b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=6f52ef30e5634b1104b372c266ca8cc80b451c7d


commit 6f52ef30e5634b1104b372c266ca8cc80b451c7d
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Sun Jun 5 10:42:22 2022 -0700

    grep: don’t diagnose "grep '\-c'"
    
    * src/grep.c (main): Skip past leading backslash of a pattern that
    begins with "\-".  Inspired by a remark by Bruno Haible in:
    https://lists.gnu.org/r/bug-gnulib/2022-06/msg00022.html

diff --git a/src/grep.c b/src/grep.c
index 59d3431..9b9407d 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -2848,8 +2848,16 @@ main (int argc, char **argv)
     }
   else if (optind < argc)
     {
+      /* If a command-line regular expression operand starts with '\-',
+         skip the '\'.  This suppresses a stray-backslash warning if a
+         script uses the non-POSIX "grep '\-x'" to avoid treating
+         '-x' as an option.  */
+      char const *pat = argv[optind++];
+      bool skip_bs = (matcher != F_MATCHER_INDEX
+                      && pat[0] == '\\' && pat[1] == '-');
+
       /* Make a copy so that it can be reallocated or freed later.  */
-      pattern_array = keys = xstrdup (argv[optind++]);
+      pattern_array = keys = xstrdup (pat + skip_bs);
       idx_t patlen = strlen (keys);
       keys[patlen] = '\n';
       keycc = update_patterns (keys, 0, patlen + 1, "");

-----------------------------------------------------------------------

Summary of changes:
 src/grep.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)


hooks/post-receive
-- 
grep



reply via email to

[Prev in Thread] Current Thread [Next in Thread]