bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH 2/3] dfa: new option DFA_STRAY_BACKSLASH_WARN


From: Bruno Haible
Subject: Re: [PATCH 2/3] dfa: new option DFA_STRAY_BACKSLASH_WARN
Date: Sun, 05 Jun 2022 03:45:56 +0200

Paul Eggert wrote:
> > This warning punishes a traditional habit, namely to backslash-escape
> > a leading ASCII '-' character, so as to avoid it from being interpreted
> > as an option.
> 
> ... These days, although I would think 'grep -- PAT FILE' would work
> everywhere

Yes, these days "grep -- PAT FILE" is one of the three common recommendations,
but "grep '\-x' FILE" and "grep -e -x FILE" are the other ones. [1][2]

> If we want to support "grep '\-PAT' FILE", we can do so in grep rather 
> than in dfa.c

Yes, grep.c looks like the better place to do this handling, rather than
dfa.c and/or regex.c. Because the command-line handling is done in grep.c.
And maybe some people find it OK to get the "stray \ before -" warning for
  grep -e '\-x' FILE
and to inhibit it only when the option -e or the marker '--' is not used?

Bruno

[1] 
https://stackoverflow.com/questions/2427913/how-can-i-grep-for-a-string-that-begins-with-a-dash-hyphen
[2] 
https://unix.stackexchange.com/questions/541488/how-do-i-use-grep-to-search-for-the-string-1






reply via email to

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