Live data from Hacker News

We are stuck with egrep and fgrep (unless you like beating people)

utcc.utoronto.ca

111–120 of 354 posts

Re: We are stuck with egrep and fgrep (unless you like beating people)

#111

Earlier quoted context omitted.

#!/bin/sh exec grep -E "$@"

Of course it can be solved; no one claimed you can't. The choice here is: - Thousands of users have to update their scripts, habits, shell configs; or - The GNU Grep maintainers spend essentially zero minutes "maintaining" a few lines of code to automatically use -E or -F based on argv[0]. It seems to me the second is obviously the better option.

So. Thought experiment.

Which has lower cognitive load if everyone starts doing it?

Explicitly specifying switches, or argv magic? I'd argue, the switches are. In the abscence of the symlinking, that is how the tool functionality would have to be driven anyway.

Argv magic now runs into a problem if another program sharing the name ever comes into existence on the path. It's also completely unergonomic in a sense, because short of looking at the source, you have no way of knowing what argv transforms implementations support are, and in order to use them, you must explicitly pollute the Symbol namespace with a denormalized util. Also, the argv magic does require one extra shell to do the transform from !grep to grep -!, Which is technically more overhead. On the other hand, fgrep and egrep are ironically easier to grep/sed for as opposed to grep/ -[F|E]

One tool, one manual, one name, one argv0.

I am not the Grand Poobah of the Internet, however, even if their hat is in my possession, so I understand that it is likely that the fgrep/egrep convention is probably deeply entrenched, and likely to spawn a new holy war on par with Emacs/Vim. Tabs/spaces, etc...

Re: We are stuck with egrep and fgrep (unless you like beating people)

#112
post #91
post #66

Earlier quoted context omitted.

You have two options: The first option is to simply replace "fgrep" with "grep -F" everywhere in all your scripts, which is correct but is more work than your other option, which is to add your own "fgrep" script somewhere in your path. Any of these options seem reasonable to me.

OK, are you going to call up all my former employers to tell them to audit the scripts I wrote for them in the late 90's? I really don't think people understand the impact here. It's not it's just a bunch of angry geriatric graybeards yelling at the modern world. It's that there is decades of uncounted, unrecognized, untraceable software written using these old conventions that are suddenly changing. It's just a terr…

Either a system is frozen and static, in which case it will not receive this version of GNU grep, and there is no problem. On the other hand, if a system receives updates, the system needs both minor and major changes all the time, to keep up with its ever-changing environment. This is the jungle in which we live. Linux syscalls are important to keep, since it’s hard to change a compiled binary. But it’s easy to change a shell script.

And don’t exaggerate. This won’t, in all likelihood, “break” your scripts.

Re: We are stuck with egrep and fgrep (unless you like beating people)

#113

GNU Grep manpage says: 7th Edition Unix had commands egrep and fgrep that were the counterparts of the modern ‘grep -E’ and ‘grep -F’. Although breaking up grep into three programs was perhaps useful on the small computers of the 1970s, egrep and fgrep were not standardized by POSIX and are no longer needed. In the current GNU implementation, egrep and fgrep issue a warning and then act like their modern counterparts…

GNU: GNU is Not Unix. Or Linux for that matter.

Re: We are stuck with egrep and fgrep (unless you like beating people)

#114

I use fgrep all the time. Why should I spend time converting scripts, and retraining my fingers, and forever after taking longer to type grep -F? This is a breaking change that has no upside, only downside. It is idiocy. Just to elaborate, there must be many thousands (hundreds of thousands? millions?) of shell scripts out there that use fgrep. For no reason at all (whatever maintenance burden fgrep represents must b…

There's a certain type of person who gets pleasure from following rules exactly, particularly when other people don't follow those rules. A kind of smug moral superiority.

If they get into a position of power, they can make life worse for other people, without much regard for the actual cost of breaking such rules.

Removing egrep and fgrep is desperately petty stuff.

Re: We are stuck with egrep and fgrep (unless you like beating people)

#116

I’ve been using grep -E for a long time, I thought I remember it being from a warning from egrep or something.. can’t really remember for sure, though. Either way, I don’t see what the big deal is, just add an alias egrep='grep -E' If you’re worried about your non-interactive shell scripts, shopt -s expand_aliases; alias egrep='grep -E' and you can move on with your life. EDIT: I must’ve been warned by shellcheck EDI…

It’s a matter of principle. If you wrote a script yesterday (or a year ago) and didn’t include that line, you need to re-release it today. That’s stupid. Also, you’re being very sanctimonious about this but what if you didn’t see this HN story. Would you know to do that for the next script you distribute?

[deleted]

Re: We are stuck with egrep and fgrep (unless you like beating people)

#117
post #2

What problem is this warning trying to solve? Are these two symlinks too much maintenance burden? Or is the check in the code hurting the code quality? Is the extra check at startup ruining performance? I'm usually in favour of having one way to do things but in this case, with this much legacy it just doesn't seem worth it.

The problem is people being wrong, and the upside is feeling good about punishing them. IMO.

Re: We are stuck with egrep and fgrep (unless you like beating people)

#118
Here is what I gave for 'fgrep' on Slackware 15:

cat /bin/egrep

#!/bin/sh

exec grep -E "$@"

Is that really hard to maintain :) I was expecting to see a link, but instead it is a shell script GNU is asking is to create. I do not know why GNU says that is hard to maintain going forward. BTW, this is grep v3.7

Re: We are stuck with egrep and fgrep (unless you like beating people)

#119

They (the maintainer) should make the behavior of `grep` depending on the name of the executable. Then one could simply do a `ln -s grep egrep` and be done with it.

That's exactly what it does already. The maintainers are objecting to the existence of the links.

Re: We are stuck with egrep and fgrep (unless you like beating people)

#120

Happy to have left the mess that is grep, awk, bash, zsh, fish, etc. behind and just use Python for scripting.

Python has it's own problems. Not the least of which being it being hundreds of times slower than coreutils.

I'll take learning Shell and a handful of coreutils, over praying the sysadmin has successfully navigated/allowed me to navigate all the Python footguns.

Also, good luck doing anything embedded where space is at a premium. Not all base systems have/need Python. Everything needs a shell, however.

Post reply on HN