lib/utilities: fix `_bash-it-grep()`

1. Executing `'/usr/bin/grep'` does *not* return the path to grep...
2. use `type -p` instead of external binary `which`.
3. Simplify parameter definition.
4. Why was there a space after `%s`?
pull/1933/head
John D Pell 2021-09-08 16:09:44 -07:00
parent 120dee2569
commit 22ea7d34bc
1 changed files with 4 additions and 5 deletions

View File

@ -60,11 +60,10 @@ _bash-it-array-dedup() {
} }
# Outputs a full path of the grep found on the filesystem # Outputs a full path of the grep found on the filesystem
_bash-it-grep() { function _bash-it-grep()
if [[ -z "${BASH_IT_GREP:-}" ]] ; then {
export BASH_IT_GREP="$(which egrep || which grep || '/usr/bin/grep')" : "${BASH_IT_GREP:=$(type -p egrep || type -p grep)}"
fi printf "%s" "${BASH_IT_GREP:-'/usr/bin/grep'}"
printf "%s " "${BASH_IT_GREP}"
} }