GNU bug report logs - #65046
Error in the "grep" documentation, section "2.1.7 Other Options": "--"

Previous Next

Package: grep;

Reported by: "Helmut Waitzmann Anti-Spam-Ticket.b.qc3c" <oe.throttle <at> xoxy.net>

Date: Fri, 4 Aug 2023 03:57:02 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 65046 in the body.
You can then email your comments to 65046 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-grep <at> gnu.org:
bug#65046; Package grep. (Fri, 04 Aug 2023 03:57:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Helmut Waitzmann Anti-Spam-Ticket.b.qc3c" <oe.throttle <at> xoxy.net>:
New bug report received and forwarded. Copy sent to bug-grep <at> gnu.org. (Fri, 04 Aug 2023 03:57:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Helmut Waitzmann <ml.throttle <at> xoxy.net>
To: GNU grep bug reporting team <bug-grep <at> gnu.org>
Subject: Error in the "grep" documentation, section "2.1.7 Other Options": "--"
Date: Thu, 03 Aug 2023 21:57:23 +0200
[Message part 1 (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 2 (application/pgp-signature, inline)]

Reply sent to Paul Eggert <eggert <at> cs.ucla.edu>:
You have taken responsibility. (Sun, 06 Aug 2023 01:56:02 GMT) Full text and rfc822 format available.

Notification sent to "Helmut Waitzmann Anti-Spam-Ticket.b.qc3c" <oe.throttle <at> xoxy.net>:
bug acknowledged by developer. (Sun, 06 Aug 2023 01:56:02 GMT) Full text and rfc822 format available.

Message #10 received at 65046-done <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: "Helmut Waitzmann Anti-Spam-Ticket.b.qc3c" <oe.throttle <at> xoxy.net>
Cc: 65046-done <at> debbugs.gnu.org
Subject: Re: bug#65046: Error in the "grep" documentation, section "2.1.7
 Other Options": "--"
Date: Sat, 5 Aug 2023 18:54:54 -0700
[Message part 1 (text/plain, inline)]
Thanks for reporting that. I installed the attached patch.
[0001-doc-clarify-role.patch (text/x-patch, attachment)]

Information forwarded to bug-grep <at> gnu.org:
bug#65046; Package grep. (Sun, 06 Aug 2023 06:33:18 GMT) Full text and rfc822 format available.

Message #13 received at 65046-done <at> debbugs.gnu.org (full text, mbox):

From: Helmut Waitzmann <v_a-brxx.throttle <at> xoxy.net>
To: "Paul Eggert" <eggert <at> cs.ucla.edu>
Cc: 65046-done <at> debbugs.gnu.org
Subject: Re: bug#65046: Error in the "grep" documentation,
 section "2.1.7 Other Options": "--"
Date: Sun, 06 Aug 2023 04:06:58 +0200
[Message part 1 (text/plain, inline)]
 Paul Eggert:
> Thanks for reporting that. I installed the attached patch.

 Thank you.

 Kind regards

 Helmut Waitzmann
[Message part 2 (application/pgp-signature, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 03 Sep 2023 11:24:07 GMT) Full text and rfc822 format available.

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.