Live data from Hacker News

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

utcc.utoronto.ca

251–260 of 354 posts

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

#251

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.

We've seen a lot of this in recent years.

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

#252

Earlier quoted context omitted.

At a guess, it isn't actually the symlinks, it's the argument parsing they're trying to simplify. Old programs have stupidly complex argument parsing. If you can pass your arguments as "cmd foo bar path", "cmd -f bar path", "cmd -fbar path", "cmd path --foo=bar" or "fcmd bar path" and "cmdf path bar", it can be really convenient for users who can structure their commands in the way that makes the most sense for them.…

> At a guess, it isn't actually the symlinks, it's the argument parsing they're trying to simplify. There’s no parsing. GNU’s egrep and fgrep are trivial shell scripts: #!/bin/sh exec grep -E "$@"

Then that's a real jerk-ass move.

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

#253

Earlier quoted context omitted.

> though it has already been committed to git for more than a year now and this is the first I've heard people complain about the change. This reasoning is flawed. I only noticed it a few months back on Arch. So between the time it takes the project to make a new release and it hitting Linux distros (Debian is slower and Ubuntu even moreso), don’t expect a flood of complaints to be time correlated with the change.

> This reasoning is flawed. I wasn't making any reasoning. I was just making the observation that this change has been staged for a while now and that I'm surprised there hasn't been more noise about it before now. > don’t expect a flood of complaints to be time correlated with the change. I expect complaints to be correlated with whenever a blog/tweet/whatever moaning about the change happens to trend. I don't think…

> I was just making the observation that this change has been staged for a while now

“There’s no point in acting surprised about it. All the planning charts and demolition orders have been on display at your local planning department in Alpha Centauri for 50 of your Earth years, so you’ve had plenty of time to lodge any formal complaint and it’s far too late to start making a fuss about it now. … What do you mean you’ve never been to Alpha Centauri? Oh, for heaven’s sake, mankind, it’s only four light years away, you know. I’m sorry, but if you can’t be bothered to take an interest in local affairs, that’s your own lookout. Energize the demolition beams.”

Again, you're completely missing the point of the comment you're replying to: average users don't pay attention to what's being staged upstream. You're only going to get the real flood of complaints when it actually gets pushed out and people's houses start getting demolished.

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

#254

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.

> 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.

HN commenters in a nutshell.

Not you in particular, but oh my god, the rules-lawyering and lecturing on this site is unbearable at times.

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

#255

Earlier quoted context omitted.

You could write a little function that does that

For me, that's the biggest takeaway: Nothing is stopping users from maintaining the behavior they had previously. It's being made explicit that the burden of maintaining that behavior is changing.

What exactly do you think the burden of _not_ changing a shell script is?

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

#256

Earlier quoted context omitted.

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

The current contents (not joking): (this is why the situation is crazy) #!/bin/sh cmd=${0##\*/} echo "$cmd: warning: $cmd is obsolescent; using grep -E" >&2 exec grep -E "$@"

I cannot edit anymore, so I add this:

This is the case in a distribution (Arch) that has effectively taken the maintainer's advice into account, not the reverse.

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

#257

Earlier quoted context omitted.

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

Yep. Almost (it uses a wrapper script instead of a symlink), but it ends up being such a silly situation all the same... Thanks for pointing it out though, I was not aware!

I cannot edit anymore, so I add this: This is the case in a distribution (Arch) that has effectively taken the maintainer's advice into account, not the reverse.

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

#258

Earlier quoted context omitted.

The gnu coding standards has this to say: https://www.gnu.org/prep/standards/standards.html#index-beha... Please don’t make the behavior of a utility depend on the name used to invoke it. It is useful sometimes to make a link to a utility with a different name, and that should not change what it does. The next section provides some reasoning: Providing valid information in argv[0] is a convention, not guaranteed. Wel…

Different behavior based on argv[0] was first brought to my attention when I discovered that /bin/sh was a symlink on some Linux systems. Bash has a Bourne shell compatibility mode.

Busybox is the forefront example of this in my mind. Busybox is a single binary that provides a ton of POSIX utilities (including sh, awk, ls, cp, nc, rm, gzip, and about 300 other common ones), and these can be invoked with `busybox $command`, or a symlink may be made from the command name to the `busybox` binary to automatically do the same. Many embedded Linux systems just use busybox and a ton of symlinks to act as the majority of the userland.

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

#259
post #42

Earlier quoted context omitted.

I betcha most people didn't even know they were considered "deprecated".

There is so much outdated info on the internet in various forms that it is hard even to realize what is "proper modern way" of doing things unless you really are into Linux \ config stuff. I am casual user so I can get around system but modern ways always surprise me when I finally find out about it.

And for all you know "grep -E" isn't supported on some system people use. This is not really a concern if you're just writing script for yourself (which are really >90% of scripts; portability often isn't really a concern), but knowing it will work on all systems – new and old – is pretty hard, and sometimes it does matter. Does it work on NetBSD? HP-UX? Solaris? Last year autoconf changed the `..` command substitution syntax to the "new" $(..) syntax and someone complained it broke on their ancient Solaris system.

So ... people will stick with what works, like "egrep".

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

#260

Earlier quoted context omitted.

Aside: What do you mean by "use a symbolic link" (I'm familiar with `ln -s` fwiw) the alias carries the command switch, how do you do that with a link? # example alias egrep='grep -E' ??

Currently, egrep and fgrep are shell scripts (the too-simple version of this idea would be #!/bin/sh exec /usr/bin/grep -E "$@" but that would mess up help messages and probably also needs disaster handling in case exec fails). Another traditional way, however, is to symlink everything to a single binary, which uses argv[0] or getprogname() to see which name the user called it under and acts accordingly. In the extre…

Actually it turns out that, at least in debian 11, you were right on the money:

    cat `which egrep`
    #!/bin/sh
    exec grep -E "$@"
But I agree that it would be cleaner and trivial to implement this behavior by depending on argv[0], GNU style guide be damned.
Post reply on HN