lib/grep, etc: avoid obsolete egrep/fgrep

https://github.com/Bash-it/bash-it/issues/2163
This commit is contained in:
Koichi Murase 2022-09-29 18:24:24 +09:00
parent 62b0724471
commit 20cbf8d226
5 changed files with 11 additions and 8 deletions

View File

@ -44,10 +44,10 @@ _python_django_completion()
{
if [[ ${COMP_CWORD} -ge 2 ]]; then
PYTHON_EXE=$( basename -- ${COMP_WORDS[0]} )
echo $PYTHON_EXE | egrep "python([2-9]\.[0-9])?" >/dev/null 2>&1
echo $PYTHON_EXE | command grep -E "python([2-9]\.[0-9])?" >/dev/null 2>&1
if [[ $? == 0 ]]; then
PYTHON_SCRIPT=$( basename -- ${COMP_WORDS[1]} )
echo $PYTHON_SCRIPT | egrep "manage\.py|django-admin(\.py)?" >/dev/null 2>&1
echo $PYTHON_SCRIPT | command grep -E "manage\.py|django-admin(\.py)?" >/dev/null 2>&1
if [[ $? == 0 ]]; then
COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]:1}" \
COMP_CWORD=$(( COMP_CWORD-1 )) \

View File

@ -91,7 +91,7 @@ function __fab_completion() {
-*)
if [[ -z "${__FAB_COMPLETION_LONG_OPT}" ]]; then
export __FAB_COMPLETION_LONG_OPT=$(
fab --help | egrep -o "\-\-[A-Za-z_\-]+\=?" | sort -u)
fab --help | command grep -Eo "\-\-[A-Za-z_\-]+\=?" | sort -u)
fi
opts="${__FAB_COMPLETION_LONG_OPT}"
;;
@ -101,7 +101,7 @@ function __fab_completion() {
# -*)
# if [[ -z "${__FAB_COMPLETION_SHORT_OPT}" ]]; then
# export __FAB_COMPLETION_SHORT_OPT=$(
# fab --help | egrep -o "^ +\-[A-Za-z_\]" | sort -u)
# fab --help | command grep -Eo "^ +\-[A-Za-z_\]" | sort -u)
# fi
# opts="${__FAB_COMPLETION_SHORT_OPT}"
# ;;

View File

@ -17,7 +17,7 @@ function _vault_mounts() {
}
function _vault() {
local VAULT_COMMANDS=$(vault 2>&1 | egrep '^ +' | awk '{print $1}')
local VAULT_COMMANDS=$(vault 2>&1 | command grep -E '^ +' | awk '{print $1}')
local cur
local prev

View File

@ -24,8 +24,11 @@ fi
# export grep settings
if ((${#_omb_grep_options[@]} > 0)); then
_omb_util_alias grep="grep ${_omb_grep_options[*]}"
_omb_util_alias fgrep="fgrep ${_omb_grep_options[*]}"
_omb_util_alias egrep="egrep ${_omb_grep_options[*]}"
_omb_util_alias fgrep="grep -F ${_omb_grep_options[*]}"
_omb_util_alias egrep="grep -E ${_omb_grep_options[*]}"
else
_omb_util_alias fgrep='grep -F'
_omb_util_alias egrep='grep -E'
fi
# clean up

View File

@ -139,7 +139,7 @@ ___brainy_prompt_todo() {
_omb_util_binary_exists todo.sh || return
color=$_omb_prompt_bold_white
box="[|]"
info="t:$(todo.sh ls | egrep "TODO: [0-9]+ of ([0-9]+)" | awk '{ print $4 }' )"
info="t:$(todo.sh ls | command grep -E "TODO: [0-9]+ of ([0-9]+)" | awk '{ print $4 }' )"
printf "%s|%s|%s|%s" "${color}" "${info}" "${_omb_prompt_bold_green}" "${box}"
}