GNU bug report logs - #63819
Gnu `grep '.*'` does not match an empty string.

Previous Next

Package: grep;

Reported by: "Bob Vincent Il (US)" <robert.a.vincent.ii <at> pwc.com>

Date: Wed, 31 May 2023 23:02:02 UTC

Severity: normal

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

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#63819: closed (Gnu `grep '.*'` does not match an empty string.)
Date: Thu, 01 Jun 2023 03:16:01 +0000
[Message part 1 (text/plain, inline)]
Your message dated Wed, 31 May 2023 20:15:30 -0700
with message-id <9f737863-fbad-b673-930d-e5ccca682266 <at> cs.ucla.edu>
and subject line Re: bug#63819: Gnu `grep '.*'` does not match an empty string.
has caused the debbugs.gnu.org bug report #63819,
regarding Gnu `grep '.*'` does not match an empty string.
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
63819: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=63819
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: "Bob Vincent Il (US)" <robert.a.vincent.ii <at> pwc.com>
To: "bug-grep <at> gnu.org" <bug-grep <at> gnu.org>
Subject: Gnu `grep '.*'` does not match an empty string.
Date: Wed, 31 May 2023 17:18:30 +0000
[Message part 3 (text/plain, inline)]
I discovered only today that the following commands all behave identically:

  *   grep -q '.*'
  *   grep -q '.\+'
  *   grep -q .
  *   grep -qE '.*'
  *   grep -qE '.+'
  *   grep -qE .

Gnu grep documentation says:

The period ‘.’ matches any single character. It is unspecified whether ‘.’ matches an encoding error.
and
‘*’

The preceding item is matched zero or more times.

I would think that an empty string matches "zero or more of any single character".

Can anyone point out where the documentation says otherwise?



Bob Vincent (US)<mailto:robert.a.vincent.ii <at> pwc.com>

PwC IT - NGC - PUPPET DEV OPS<https://wwwpwcnetwork.pwc.myshn.net/nav_to.do?uri=sys_user_group.do?sys_id=16aec8f0db7e145cd9703423f39619de> | Senior Manager

Work: 906-984-3549<tel:+1.906.984.3549>
Mobile: 770-744-1792<tel:+1.770.744.1792>
PricewaterhouseCoopers LLP
@workday<https://wd3.myworkday.com/pwc/d/inst/1$37/247$701091.htmld> @github<https://github.pwc.com/robert-a-vincent-ii> @ServiceNow<https://wwwpwcnetwork.pwc.myshn.net/nav_to.do?uri=sys_user.do?sys_id=2421e2591b2e081483c254207e4bcb7b%26sysparm_view=ess>


________________________________

The information transmitted, including any attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited, and all liability arising therefrom is disclaimed. If you received this in error, please contact the sender and delete the material from any computer.


In the event the content of this email includes Tax advice, the content of this email is limited to the matters specifically addressed herein and is not intended to address other potential tax consequences or the potential application of tax penalties to this or any other matter.


PricewaterhouseCoopers LLP is a Delaware limited liability partnership. This communication may come from PricewaterhouseCoopers LLP or one of its subsidiaries.

________________________________
[Message part 4 (text/html, inline)]
[Message part 5 (message/rfc822, inline)]
From: Paul Eggert <eggert <at> cs.ucla.edu>
To: "Bob Vincent Il (US)" <robert.a.vincent.ii <at> pwc.com>
Cc: 63819-done <at> debbugs.gnu.org
Subject: Re: bug#63819: Gnu `grep '.*'` does not match an empty string.
Date: Wed, 31 May 2023 20:15:30 -0700
On 2023-05-31 19:17, Bob Vincent Il (US) wrote:
> Okay, but `echo ''` does not output an empty string. It outputs a line feed character.

The line feed is not considered. Grep looks only for matches of "any 
part of the line excluding the terminating <newline>" 
<https://pubs.opengroup.org/onlinepubs/9699919799/utilities/grep.html>.

Closing the bug report as it appears to be due to a misunderstanding of 
how 'grep' works.


This bug report was last modified 2 years and 50 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.