GNU bug report logs -
#65046
Error in the "grep" documentation, section "2.1.7 Other Options": "--"
Previous Next
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your message dated Sat, 5 Aug 2023 18:54:54 -0700
with message-id <d64fb616-5a8c-2daf-d1dd-fd9c5f330c26 <at> cs.ucla.edu>
and subject line Re: bug#65046: Error in the "grep" documentation, section "2.1.7 Other Options": "--"
has caused the debbugs.gnu.org bug report #65046,
regarding Error in the "grep" documentation, section "2.1.7 Other Options": "--"
to be marked as done.
(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)
--
65046: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=65046
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
[Message part 3 (text/plain, inline)]
Hello, GNU grep bug reporting team,
in the section "2.1.7 Other Options" of the "grep" "info"
documentation (for example in
<https://www.gnu.org/software/grep/manual/html_node/Other-Options.html>),
the hint about the usage of the "--" option delimiter is wrong:
It won't work, if the pattern "PAT" happens to start with a "-".
And if the environment variable "POSIXLY_CORRECT" is set, it
won't even work with any pattern (except the pattern "--").
The following example may show it:
How to reproduce: In an empty directory, run the following
commands:
printf '%s\n' -1 +1 > -file1 &&
printf '%s\n' -2 +2 > file2 &&
grep '-[[:digit:]]' -- -file1 file2
Received output:
grep: invalid option -- '['
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
Expected output: According to the manual, the output should be
-file1:-1
file2:-2
=> The hint in the documentation is wrong: Rather than
‘--’
Delimit the option list. Later arguments, if any, are
treated as operands even if they begin with ‘-’. For
- example, ‘grep PAT -- -file1 file2’ searches for the
pattern PAT in the files named ‘-file1’ and ‘file2’.
it should say:
‘--’
Delimit the option list. Later arguments, if any, are
treated as operands even if they begin with ‘-’. For
+ example, ‘grep -- PAT -file1 file2’ searches for the
pattern PAT in the files named ‘-file1’ and ‘file2’.
(the differing lines are marked in the first position with "-"
resp. "+").
Working example:
printf '%s\n' -1 +1 > -file1 &&
printf '%s\n' -2 +2 > file2 &&
grep -- '-[[:digit:]]' -file1 file2
Received output:
-file1:-1
file2:-2
Explanation: As the pattern PAT shall be the first non-option
argument given to "grep", the option list delimiter "--", when
placed before the pattern in "grep"s invocation arguments list,
prevents the pattern from being misinterpreted as an option
(regardless of the POSIXLY_CORRECT environment variable being set
or unset).
Kind regards
Helmut Waitzmann
[Message part 4 (application/pgp-signature, inline)]
[Message part 5 (message/rfc822, inline)]
[Message part 6 (text/plain, inline)]
Thanks for reporting that. I installed the attached patch.
[0001-doc-clarify-role.patch (text/x-patch, attachment)]
This bug report was last modified 1 year and 292 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.