completions/brew: Protect against pathname expansions and refactor

This commit is contained in:
Koichi Murase
2022-01-08 15:34:05 +09:00
parent b05f53558b
commit eaa147afa6
+10 -6
View File
@@ -1,9 +1,13 @@
if which brew >/dev/null 2>&1; then
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
if _omb_util_command_exists brew; then
_omb_completion_brew_prefix=$(brew --prefix)
if [[ $_omb_completion_brew_prefix ]]; then
if [[ -f $_omb_completion_brew_prefix/etc/bash_completion ]]; then
source "$_omb_completion_brew_prefix"/etc/bash_completion
fi
if [ -f `brew --prefix`/Library/Contributions/brew_bash_completion.sh ]; then
. `brew --prefix`/Library/Contributions/brew_bash_completion.sh
if [[ -f $_omb_completion_brew_prefix/Library/Contributions/brew_bash_completion.sh ]]; then
source "$_omb_completion_brew_prefix"/Library/Contributions/brew_bash_completion.sh
fi
fi
unset -v _omb_completion_brew_prefix
fi