bash-it icon indicating copy to clipboard operation
bash-it copied to clipboard

[Bug]: "egrep: warning: egrep is obsolescent"

Open holic-cl opened this issue 2 years ago • 5 comments

Expected behavior

I expect to have a clean interaction with my shell

Current behavior

Every interaction i do on my terminal is warning me:

egrep: warning: egrep is obsolescent; using grep -E

Possible solution

No response

Context

No response

Steps to reproduce

Use Debian unstable with bash and install bash-it

Bash-it version

v3.0.2 (stable)

List of enabled plugins, themes and aliases

plugins:base, aliases: general, kubectl

Bash version

5.2.0(1)-rc2 (x86_64-pc-linux-gnu)

Operating system and version

Debian GNU/Linux bookworm/sid

bash-it doctor output

# How to get: bash-it doctor

Your ~/.bashrc

# How to get: cat ~/.bashrc
DEBUG: core: main: Loading libraries(except appearance)...
DEBUG: lib: colors: Loading library file...
DEBUG: lib: command_duration: Loading library file...
DEBUG: lib: helpers: Loading library file...
DEBUG: lib: history: Loading library file...
DEBUG: lib: log: Loading library file...
DEBUG: lib: preexec: Loading library file...
DEBUG: lib: preview: Loading library file...
DEBUG: lib: search: Loading library file...
DEBUG: lib: utilities: Loading library file...
DEBUG: core: reloader: Loading all enabled components...
DEBUG: aliases: general: Loading component...
DEBUG: aliases: general: Command 'gshuf' does not exist
DEBUG: aliases: general: Loaded.
DEBUG: aliases: kubectl: Loading component...
DEBUG: aliases: kubectl: Loaded.
DEBUG: plugin: base: Loading component...
DEBUG: plugin: base: Command 'markdown' does not exist
DEBUG: plugin: base: Loaded.
DEBUG: completion: system: Loading component...
DEBUG: completion: system: Loaded.
DEBUG: completion: bash-it: Loading component...
DEBUG: completion: bash-it: Loaded.
DEBUG: completion: kubectl: Loading component...
DEBUG: completion: kubectl: Loaded.
DEBUG: completion: minikube: Loading component...
DEBUG: completion: minikube: Loaded.
DEBUG: completion: aliases: Loading component...
DEBUG: completion: aliases: Loaded.
DEBUG: core: main: Loading theme 'powerline'.
DEBUG: core: main: Loading custom aliases, completion, plugins...
DEBUG: core: main: Loading general custom files...
DEBUG: custom: example: Loading custom file...
DEBUG: core: main: Command 'gloobus-preview' does not exist

Notes

No response

holic-cl avatar Sep 09 '22 05:09 holic-cl

For some context, you all may have noticed either the HN article, the blog it links to, or the updated man page for the newly released grep 3.8:

  • https://news.ycombinator.com/item?id=32717184
  • https://www.phoronix.com/news/GNU-Grep-3.8-Stop-egrep-fgrep
  • https://www.gnu.org/software/grep/manual/grep.html

From the man page:

What happened to egrep and fgrep? 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; eventually, they are planned to be removed entirely.

Bash-it has a builtin function, _bash-it-egrep that abstracts the invocation of egrep, but there are still a bunch of direct invocations of egrep in the code base as well:

  • https://github.com/Bash-it/bash-it/search?q=egrep

We probably need to put together a PR to update the function and also replace the direct invocations to either use grep -E or use our function.

davidpfarrell avatar Sep 09 '22 17:09 davidpfarrell

I also have this warning printed twice everytime I press Return on terminal. For now, I just edited lines 65 and 71 of lib/utilities.bash to just use grep or grep -E. Seems to work as a temporal solution.

jujimenezp avatar Sep 11 '22 21:09 jujimenezp

Ok I got a PR ( #2164 ) started to hopefully fix this issue and silence the warnings.

As more people update to the latest gnu grep, this error is just going to become more prevelent.

davidpfarrell avatar Sep 12 '22 00:09 davidpfarrell

Was just about to create a similar issue, glad it's been raised already and hopefully will be fixed soon. In the mean time, is it safe to comment out?

dedguy21 avatar Sep 20 '22 07:09 dedguy21

@dedguy21

[I]s it safe to comment out?

No, that would probably blow up, but for the completions/plugins/themes that you use that are exhibiting this issue, you can modify them locally to use grep -E instead of egrep

Additionally, this change in utilities file could be helpful.

lib/utilities.bash

function _bash-it-egrep() {
-	: "${BASH_IT_GREP:=$(type -P egrep || type -P grep)}"
+	: "${BASH_IT_GREP:=$(type -P grep)}"
	"${BASH_IT_GREP:-/usr/bin/grep}" -E "$@"
}

NOTE You'll need to revert these changes before upgrading your bash-it in the future (say, after my egrep fix gets merged)

davidpfarrell avatar Sep 20 '22 15:09 davidpfarrell

Ran your PR in Arch Linux with bash version 5.1.16.

Works like a charm.

Thanks.

dedguy21 avatar Sep 23 '22 17:09 dedguy21

I wonder when we can expect egrep patch in stable. This obsolesces info at each prompt is extremely annoying.

nbvcxz avatar Sep 29 '22 08:09 nbvcxz