lib/utilities: simplify `_bash-it-array-dedup()`

alsö fix usage example of `_bash-it-array-contains-element()`
pull/1973/head
John D Pell 2021-10-13 09:27:55 -07:00
parent cf08fcaff2
commit f7cc442af4
1 changed files with 3 additions and 4 deletions

View File

@ -40,7 +40,7 @@ function _bash-it-get-component-type-from-path() {
# $ _bash-it-array-contains-element apple "@{fruits[@]}" && echo 'contains apple' # $ _bash-it-array-contains-element apple "@{fruits[@]}" && echo 'contains apple'
# contains apple # contains apple
# #
# $ if $(_bash-it-array-contains-element pear "${fruits[@]}"); then # $ if _bash-it-array-contains-element pear "${fruits[@]}"; then
# echo "contains pear!" # echo "contains pear!"
# fi # fi
# contains pear! # contains pear!
@ -54,10 +54,9 @@ function _bash-it-array-contains-element() {
return 1 return 1
} }
# Dedupe a simple array of words without spaces. # Dedupe an array (without embedded newlines).
function _bash-it-array-dedup() { function _bash-it-array-dedup() {
local IFS=$'\n' printf '%s\n' "$@" | sort -u
echo "$@" | tr ' ' '\n' | sort -u
} }
# Outputs a full path of the grep found on the filesystem # Outputs a full path of the grep found on the filesystem