by koprulusector · 4y ago · 0 comments
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
EDIT2: here’s another one liner with one caveat being updates (also needs to be run as root)
# unalias grep && unalias egrep && cp "$(command -v grep)" "$(dirname "$(command -v grep)")/egrep"
EDIT3: just realized for most this will only ever come up in scripts because many distros already add alias egrep='grep -E' to your shell aliases (~/.bash_aliases, ~/.zshrc, etc). Thus you may only need the shopt -s expand_aliases.We shouldn't change the oldest parts of our OSes without a really good reason.
I'm fine with this clean-up and simplification. Eventually, there will be more future users of `grep` than past users.
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?
That said, to answer your questions directly: hopefully you aren’t auto updating anywhere in production or important, so this won’t effect anything until the box has grep 3.8. Ubuntu 20.04 uses grep 3.4, for example.
And the warning prints to stderr, so honestly, I'm having a difficult time seeing this being an actual problem for more than 0.1% of users.
I’m not unsympathetic to those that it adversely affects, but I genuinely haven’t seen anyone point out any severe consequences of the change. I’m not saying it’s impossible, if someone has a real example (sorry, saying you might get a page on the weekend for a warning printed to stderr is a stretch), I’m all ears.
Emphasis on "I", which says strictly nothing of the rest of CLI users out there.
We're very glad to learn that it is not a problem for you, but it brings very little to the conversation.
Worth reading the guidelines [0].
The man page for GNU grep says:
In addition, the variant programs egrep, fgrep and rgrep are the same
as grep -E, grep -F, and grep -r, respectively. These variants are
deprecated, but are provided for backward compatibility.
"Deprecated" should be read as "maybe ain't gonna be around one day". "Use interactively, or in your personal setup, but don't put into shipping code".So if you wrote a script yesterday with these things, you're just one of those people who don't look into specs or man pages.
The scripts of coders who don't read documentation are going to tend not to be portable or reliable anyway. That doesn't mean we should break things left and right to trip people up, but in this case the writing has been on the wall for a very long time.