Subject: bug#68592: Grep 3.1 does not recognize regex beginning-of-line and end-of-line anchors (^ and $). on RHEL 8.9

From: Erich Wolz <[email-masked]>
Date: Tue, 23 Jan 2024 17:53:43 +0000

Hmm, it appears that the grep command is​ aliased... but invoking the binary directly doesn't change my results:

wolz:~$ which grep
alias grep='grep --color=auto'
      /usr/bin/grep
wolz:~$ type grep
grep is aliased to `grep --color=auto'
wolz:~$ env | grep GREP_OPTIONS
wolz:~$ ls -al /usr/bin/grep
-rwxr-xr-x. 1 root root 193768 Aug 12  2018 /usr/bin/grep
wolz:~$ /usr/bin/grep '.*bar$' filename1
wolz:~$ /usr/bin/grep '^foo$' filename2
wolz:~$ cat /etc/os-release | grep VERSION
VERSION="8.9 (Ootpa)"
VERSION_ID="8.9"
REDHAT_BUGZILLA_PRODUCT_VERSION=8.9
REDHAT_SUPPORT_PRODUCT_VERSION="8.9"
wolz:~$

I also was not aware that there's a newer version of grep, at least, based on the repositories I have access to:

wolz:~$ grep --version
grep (GNU grep) 3.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Mike Haertel and others, see <http://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.
wolz:~$ sudo dnf update grep
[sudo] password for wolz:
Red Hat Ansible for x86_64 (RPMs)                        9.4 kB/s | 3.0 kB     00:00
Red Hat CodeReady Builder for x86_64 (RPMs)               16 kB/s | 4.7 kB     00:00
Linux@IBM KVM Clone (RPMs)                                11 kB/s | 3.0 kB     00:00
Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)  16 kB/s | 4.7 kB     00:00
Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)     14 kB/s | 4.2 kB     00:00
Red Hat Enterprise Linux 8 for x86_64 - IBM RPMs          12 kB/s | 3.5 kB     00:00
Red Hat Enterprise Linux 8 for x86_64 - Supplementary (R  15 kB/s | 4.2 kB     00:00
resolving
Dependencies resolved.
Nothing to do.
Complete!
wolz:~$

Looks like I'll start by asking our IT support folks to update their repository version of grep!

Thanks,
Erich W. Wolz (wolz @ us.ibm.com), Senior IT Specialist
IBM Consulting - US Federal
12301 Kurland Dr., Houston, TX  77034-4812
Phone: 713-797-4645
________________________________
From: Paul Eggert <[email-masked]>
Sent: Friday, January 19, 2024 11:37 PM
To: Sam James <[email-masked]>; Erich Wolz <[email-masked]>
Cc: [email-masked] <[email-masked]>
Subject: [EXTERNAL] Re: bug#68592: Grep 3.1 does not recognize regex beginning-of-line and end-of-line anchors (^ and $). on RHEL 8.9

On 2024-01-19 17:22, Sam James wrote:
> If you cannot reproduce this with the latest release of GNU grep (3.11),
> please report it to RHEL instead.
>
> It works OK for me with 3.11.

For what it works, it also works for me with grep 3.1 running on RHEL
8.5, in the C locale.

One possibility is that 'grep' is a user-interposed shell script that is
adding some options of some sort. Or perhaps the GREP_OPTIONS
environment variable is set to something squirrelly in the environment
(this environment variable was dropped in grep 3.6 partly because of bug
reports like this one).

The user can determine this by running the shell commands "type grep"
and "env" and inspecting their outputs.