So Fedora 38 has chosen to break fgrep and egrep, to the fun of everyone who has them in scripts, especially scripts in crontab entries.

$ fgrep fred /dev/null
fgrep: warning: fgrep is obsolescent; using grep -F

Adding output to standard error is an *incompatible change*. And this is happening only because the GNU Grep people are <redacted because I cannot think of quite the right phrase>.

I have filed a Fedora 38 bug over this fgrep/egrep change and we'll see if it goes anywhere. I did my best to keep my system administrator's voice down, but I did not entirely succeed in hiding my views.

https://bugzilla.redhat.com/show_bug.cgi?id=2188430

2188430 – grep-3.8 is incompatible with previous versions of grep for fgrep and egrep

One of my opinions on egrep/fgrep versus 'grep -E' and 'grep -F' is that the former are rather nicer to type than the latter, and that matters. One extra letter, all lower case, no shifting needed. And egrep and fgrep have been there for a very long time.
Unsurprisingly, usage of egrep and fgrep is common across the shell scripts (and probably other things) that are shipped by assorted open source packages. GNU Grep's decision to loudly deprecate and then remove these names is a giant and pointless middle finger to the general free/open source ecology, one that will require hundreds of projects to undertake pointless work just because GNU Grep people want to get rid of 'redundant' commands that have been there since, oh, V7 Unix in the 70s.

Fedora has not accepted the fgrep/egrep bug report and says to take it upstream; Fedora doesn't patch upstream, so they say.
The GNU Grep upstream is actively hostile to reverting this user-hostile change.

This rejection leaves Fedora with a collection of packages with broken or malfunctioning scripts. Some of those upstreams will not change, and Fedora likely will not patch them to work again.

Nice work, Fedora. Nice work, GNU Grep. This is the inevitable consequence of your decisions.

Also, Red Hat will almost inevitably reverse this GNU Grep change in the next version of Red Hat Enterprise Linux when it branches from Fedora. If they don't, they will get laughed out of the room by enterprise developers and system administrators, who are not going to change decades of scripts (or accept broken packaged ones from RHEL) because GNU Grep had a fit of narrow POSIX compliance.

@cks this is gold!

GNU […] fit of narrow POSIX compliance

/bin/false --version, anyone? (At least it doesn’t return 0 any more, or at least in Debian it doesn’t…)

@cks Would it actually need a patch? Couldn't you do it with a compat RPM that just replaced egrep and fgrep by shell scripts that did grep -E/-F ?
@penguin42 You could do it that way but then you'd have to change the main grep RPM to not package their (broken) egrep/fgrep scripts (and to require the compat RPM).
@cks I thought there was an rpm feature to overwrite stuff from another rpm? anyway, if not I was thinking 'alternatives' could be used.
@penguin42 Two RPMs can provide exactly the same file (ie, same contents), but it's an RPM error to have clashing file contents in the same name. There's also sadly no mechanism for one RPM to make another RPM's file into an alternatives thing; all RPMs involved have to buy into it (and then none provide the actual file). So everything would take RPM packaging changes for GNU Grep in some form.
@cks I guess you could try the rpm packaging change with Fedora; if you also provided the alternate; then there's no upstream change so that feels less objectionable.
@cks @penguin42 That's the one thing from Debian-based distributions that I miss the most when working with RPM-based distributions: the dpkg-divert command, which allows one package (or the sysadmin) to move aside and replace a file from another package, while keeping everything working (updates from the original package are transparently diverted to the renamed file).

@penguin42 @cks

That's the thing. The GNU egrep and fgrep _already are_ shell scripts. Paul Eggert added this change _to those shell scripts_.

https://debbugs.gnu.org/cgi/bugreport.cgi?msg=17;att=1;bug=49996;filename=0001-egrep-fgrep-now-obsolete.patch

#GNU #grep #egrep #fgrep

Error

@cks: Debian reverted that horrible grep upstream change several months ago already and IIRC intents to keep it that way forever.
@xtaran Yeah, Fedora is the first semi-major distribution I've heard of that has taken this change and not reverted it. Everyone else seems to have noped out.
@cks: Actually, on the commandline I never use grep. I always use either fgrep or egrep. grep itself looks to me like an unlucky bastard of both: Neither searches for literal strings nor does it have mighty enough regular expressions but instead just an (IMHO bad) compromise of both.
@xtaran @cks and not ack(1) ?
I use it more and more nowadays.
@ttyS1 @xtaran My not-grep searcher has drifted to rg (ripgrep), although I think I was trying out ack a while back when all of them were relatively new.

@cks: #ripgrep indeed seems slightly fast than normal #grep.

But for some cases it's still not fast enough. Which is why I wrote #pxzgrep, a wrapper around #xzgrep which can search through many compressed log files in parallel and—provided the hardware is capable enough—reduce search times from many days to a few hours: https://github.com/ETHZ-IT-SeC/pxzgrep

Cc @ttyS1

GitHub - ETHZ-IT-SeC/pxzgrep: a parallel xzgrep wrapper

a parallel xzgrep wrapper. Contribute to ETHZ-IT-SeC/pxzgrep development by creating an account on GitHub.

GitHub
@cks Personally, I'm partial to "grep -P" over "egrep/grep -E" when I need extended regular expression support. I prefer PRCE in vim with ":perldo" also.
@atoponce @cks How is this relevant? What either of us prefers doesn't mean that our preferences work their way into everyone else's code.

@orc @cks

> How is this relevant?

It's a discussion about grep(1) options, which could lead to an interesting discussion about the regex differences between "grep -E" and "grep -P".

> What either of us prefers doesn't mean that our preferences work their way into everyone else's code.

I'm not saying they should. Curious how you read that from my reply.

@atoponce @cks Grep is the particular case here, yes, but I read it as the thrice damned FSF not giving a fuck about backwards compatibility. It's why people shouldn't mess with published interfaces if at all possible. (cf: https://qz.com/646467/how-one-programmer-broke-the-internet-by-deleting-a-tiny-piece-of-code)
How one programmer broke the internet by deleting a tiny piece of code

A man in disrupted web development around the world by deleting 11 lines of code

Quartz
@orc @atoponce @cks Yes, they ought to know better -- but the original sin here is with the POSIX standards committee, which opened the way by deprecating the names themselves, for similar silly reasons (see "RATIONALE"): https://pubs.opengroup.org/onlinepubs/9699919799/utilities/grep.html
grep

@cks "a giant middle finger to the general ecology" is basically GNU writ large, tbh
@cks Yes. I was today years old the last time I used fgrep. All three have been wired into my fingers for nearly 45 years…
@SteveBellovin @cks I can't remember when I last used fgrep, but I use egrep quite often.
@cks In my 548 personal scripts I count 223 egreps and 29 greps.

@cks Here's what Pat Volkerding, creator of Slackware, has to say about this:

"a/grep-3.8-x86_64-2.txz: Rebuilt.
Folks, I rarely veto upstream, but I'm not going to entertain this nonsense. The egrep and fgrep commands were part of Unix since the 70s, continue to be included with the BSDs, and frankly, aren't hurting anything. GNU grep declared them deprecated in 2007 and when they were changed into shell scripts around 8 years ago I figured that's where it would end."

(1/3)

@cks
"I can see no logical justification to have these scripts start making noise and then to eventually pull the rug out from under any code that might be using them, so I've placed non-noisy versions of them into the package sources and will be installing those during the build. Given that the -F and -E options are part of the POSIX standard, these scripts will continue to work fine."

(2/3)

@cks

"That said, we will be continuing to change our own code over to the recommended syntax to avoid the minimal overhead incurred compared to using grep directly."

from the Slackware changelog ( http://slackware.nl/slackware/slackware64-current/ChangeLog.txt ), on Sep 7

@cks @ltlnx we had the same thing with GNU loudly warning about tail -1 ipv the newer POSIX tail -n 1, especially as many systems didn’t yet carry the latter, at that time even OpenBSD not.

The Debian package got enough complains this idiocy was patched out (I wonder if it was removed upstream as well).

One would think the GNU coreutils maintainers learnt from this desaster…

@cks The rather obvious fix against this obsoletion/code replication would of course be to:
- still create only one binary target
- which has the smarts to enable evaluation as RE’s as Extended RE’s when invoked as “egrep”, and to treat the match pattern as fixed strings rather than RE’s when invoked as “fgrep”

One binary, three hard links, no code duplication, no middle finger to existing scripting.

@cks @js Yep. Very obvious, very easy to implement, would have no impact on people who want to follow GNU and stop using fgrep and egrep… that they didn’t take that approach speaks volumes.
@js @cks what is the problem of building three binaries from the same code base? Only the CLI interface code might have duplicates. All those three CLIs can use the same core code for the actual grep logic.
@hikhvar @js The actual modern implementation of egrep and fgrep is shell scripts that exec grep -E or grep -F as appropriate, so it's even simpler. You just ship those shell scripts without the 'echo' lines that got added in GNU Grep 3.8.
@hikhvar @js @cks zero problem as for many years egrep has been a shell script calling grep -E
Just now that script has a nasty echo built in.
@cks ehh. I see your point, the blast radius here is absolutely massive. On the other hand, this is such a tiny breakage, I have a hard time justifying calling this a "middle finger".

It's highly likely this is something distro packages aren't going to just spring on everyone. If they don't just decide to patch it in themselves to save themselves the trouble of fixing who knows how many downstream packages, then it's likely they'll save it for a major distro upgrade anyway, in which case admins usually have to expect verification for this kind of breakage anyway. I don't see it making huge waves.

@dead10ck Well, in actual practice Fedora dropped this change into a regular release with no particular notice and without auditing the shipped scripts and so on for egrep and fgrep usage. The breakage is not small in my sysadmin opinion, partly due to crontabs.

And GNU Grep is demanding every project in the world with shell code (or that exec things) audit it for fgrep/egrep usage, or else. That's not small.

@cks yeah, that's not very surprising though. I would not use Fedora as an example of the breakage we can expect. Fedora is not just incautious, they actively relish pushing breaking changes just for the sake of it.

I ran Arch for 7 years as my daily driver, upgrading my packages on a daily basis, and I can't recall a single time there was a major breaking change. Fedora, on the other hand, I've been running for 4 years now and there has been a major breaking change at least once every other release. And not small ones either.

After they changed everything to systemd-resolved, I couldn't VPN into my corporate network any more and had to scramble to figure out how to fix it. When they changed everything to pipewire, my work chat program stopped being able to make sound, and sharing my screen completely crashes my video driver, leaving me with no choice but to hard reboot. The latter issue still hasn't been fixed to this day. Literally every time I upgrade the flatpak system package, all my flatpak apps suddenly stop being able to use any networking at all. The last time they upgraded openssl through its latest major version, all kinds of programs just stopped working, even official Fedora packages.

These are what I think of as big breaking changes. While I've already agreed, the blast radius of this change is massive, the fix itself is trivial. As a fellow sysadmin myself, in my opinion, having to change `egrep` to `grep -E` is pretty insignificant, on the scale of breaking changes.

And for most major distros that people actually run in servers, I would be willing to bet money that it will take years before it makes its way to end users. You can pretty much guarantee that Debian, Ubuntu, and probably even RedHat will just vendor the old shims into their packages for a while for the benefit of their users.
@cks @dead10ck That's false. This change is only in grep 3.8. Fedora 37 has grep 3.7. 3.8 was first built for Rawhide last September, explicitly didn't go into the then-current F37 release, and waited to be included in F38 months later.
@carlwgeorge @dead10ck I was unclear in my post; by 'dropped this change into a regular release' I meant that they included it in a new Fedora release (F38) with no specific notice (and without fixing scripts from other packages, etc). Fedora X to X+1 is not in my mind a 'major distro upgrade'; barring things called out specifically in release notes, I expect it to be barely noticeable (and it usually is).

@cks @dead10ck It's probably fair that the Fedora maintainer could have considered a change proposal for this to raise visibility. It's just a deprecation warning, but I acknowledge the points you've raised about the ways it can have a outsized impact.

That said, Fedora X to X+1 is absolutely a major version upgrade. Fedora is known for innovation because every six months there is an opportunity for major changes. Maintainers don't have to wait years to deliver backwards-incompatible software.

@cks @dead10ck The reason it may not usually feel like a major upgrade going between versions is due to the outstanding QA work from folks like @adamw. The updates policy also guides maintainers to keep bigger changes in Rawhide only to sort out any kinks before going into a stable Fedora release (where updates are actually quite a bit more conservative).
@cks: GNU only seems to have been developed as a Unix-like out of duress on the behalf of Stallman; I'm sure he'd much rather that everybody was using a derivative of ITS.
@cks If only there was a search tool they could have used to check through all the scripts on a typical system to find out how often they were used.
@cks I couldn't care less:
- it's a CLI with text-based I/O, which never was meant to provide the stability and determinism of a real API
- just because it's been around since then isn't a valid reason to me to stick with it, see also the case of the bin, sbin, usr/bin , usr/sbin split: http://lists.busybox.net/pipermail/busybox/2010-December/074114.html
- keeping software in sync with changes of the ecosystem around it is nothing unusual. Why should shell scripts after all be excluded from this?
Understanding the bin, sbin, usr/bin , usr/sbin split

@cks toybox is keeping them.
@cks I still use fgrep on the CLI every single time. 🙄
@cks Mine is more that they can be different simple implementations, like fgrep done in an efficient way is probably going to have a completely different kind of algorithm than (e)grep.
And I think I would intuitively pick something like pcregrep over grep -P
@lanodan @cks or just perl -ne '/xxx/ and print'
@lanodan @cks That's exactly how there came to be three programs. It was about the patterns as well as speed. Interestingly, in the V7 days egrep was fastest (very clever algorithm) but its memory use could blow up depending on the pattern. Its author got that under control a few years later.
@cks That deprecation step makes no sense as would still break so many things, might as well have just removed the commands (even if IMHO that’s the wrong direction, checking argv[0] is nothing, specially compared to all the stuff GNU does).
@lanodan They don't even check argv[0]; for years egrep and fgrep have just been cover scripts.
@cks I guess maintenance-free code is somehow hard…

@cks We ended up making the decision in Gentoo to by default install our own fgrep and egrep but allow disabling it if people want the warnings (and eventually them to be entirely gone, I suppose).

It's not worth the breakage. I did plea on the grep mailing lists but didn't get anywhere.

@thesamesam @cks It reminds me of the time glibc tried to remove SunRPC by just dropping support for it... everything broke... and it was put back. We did it again with empathy and made sure TIRPC was ready to support existing projects. It wasn't perfect, but it was better. Likewise today I think this kind of deprecation requires GNU Grep to work with downstreams to migrate entire ecosystems off of fgrep/egrep *and then* deprecate, with eventual removal. $0.02.
@codonell I wonder a about the timeline about such depredations. Removing fgrep and egrep in the close future sounds like a bad idea because changing every kind of script or any other automation will take long. Keeping the symlink/wrappers around doesn't sound to difficult either.
@thesamesam @cks looks like debian have at least temporarily reverted it too: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1019335 - not sure if any long-term decision has been made yet
#1019335 - Reconsider the egrep and fgrep deprecation - Debian Bug report logs