From 253d1213e07ad33cfadd12fe3cff128e4b22cfb8 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Thu, 7 Oct 2021 22:39:49 -0700 Subject: [PATCH] lib/utilities: new function `_bash-it-egrep()` The existing function `_bash-it-grep()` is weird. New function `_bash-it-egrep()` just does the thing without requiring two subshells and manual invocation. --- lib/utilities.bash | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/utilities.bash b/lib/utilities.bash index 52c48776..1f249b98 100644 --- a/lib/utilities.bash +++ b/lib/utilities.bash @@ -65,6 +65,12 @@ function _bash-it-grep() { printf "%s" "${BASH_IT_GREP:-'/usr/bin/grep'}" } +# Runs `grep` with extended regular expressions +function _bash-it-egrep() { + : "${BASH_IT_GREP:=$(type -p egrep || type -p grep)}" + "${BASH_IT_GREP:-/usr/bin/grep}" -E "$@" +} + ########################################################################### # Component-specific functions (component is either an alias, a plugin, or a # completion).