brew.sh: declare commands that call auto-update as an array
Follow up to #14536.
This commit is contained in:
parent
b761344428
commit
61e82290d7
@ -209,6 +209,19 @@ EOS
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# NOTE: the members of the array in the second arg must not have spaces!
|
||||||
|
check-array-membership() {
|
||||||
|
local item=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
if [[ " ${*} " == *" ${item} "* ]]
|
||||||
|
then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Let user know we're still updating Homebrew if brew update --auto-update
|
# Let user know we're still updating Homebrew if brew update --auto-update
|
||||||
# exceeds 3 seconds.
|
# exceeds 3 seconds.
|
||||||
auto-update-timer() {
|
auto-update-timer() {
|
||||||
@ -237,12 +250,16 @@ auto-update() {
|
|||||||
# If we've checked for updates, we don't need to check again.
|
# If we've checked for updates, we don't need to check again.
|
||||||
export HOMEBREW_AUTO_UPDATE_CHECKED="1"
|
export HOMEBREW_AUTO_UPDATE_CHECKED="1"
|
||||||
|
|
||||||
if [[ "${HOMEBREW_COMMAND}" == "install" ]] ||
|
AUTO_UPDATE_COMMANDS=(
|
||||||
[[ "${HOMEBREW_COMMAND}" == "upgrade" ]] ||
|
install
|
||||||
[[ "${HOMEBREW_COMMAND}" == "bump-formula-pr" ]] ||
|
upgrade
|
||||||
[[ "${HOMEBREW_COMMAND}" == "bump-cask-pr" ]] ||
|
bump-formula-pr
|
||||||
[[ "${HOMEBREW_COMMAND}" == "bundle" ]] ||
|
bump-cask-pr
|
||||||
[[ "${HOMEBREW_COMMAND}" == "release" ]] ||
|
bundle
|
||||||
|
release
|
||||||
|
)
|
||||||
|
|
||||||
|
if check-array-membership "${HOMEBREW_COMMAND}" "${AUTO_UPDATE_COMMANDS[@]}" ||
|
||||||
[[ "${HOMEBREW_COMMAND}" == "tap" && "${HOMEBREW_ARG_COUNT}" -gt 1 ]]
|
[[ "${HOMEBREW_COMMAND}" == "tap" && "${HOMEBREW_ARG_COUNT}" -gt 1 ]]
|
||||||
then
|
then
|
||||||
export HOMEBREW_AUTO_UPDATING="1"
|
export HOMEBREW_AUTO_UPDATING="1"
|
||||||
@ -290,6 +307,8 @@ auto-update() {
|
|||||||
# exec a new process to set any new environment variables.
|
# exec a new process to set any new environment variables.
|
||||||
exec "${HOMEBREW_BREW_FILE}" "$@"
|
exec "${HOMEBREW_BREW_FILE}" "$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
unset AUTO_UPDATE_COMMANDS
|
||||||
}
|
}
|
||||||
|
|
||||||
#####
|
#####
|
||||||
@ -776,7 +795,7 @@ then
|
|||||||
update-python-resources
|
update-python-resources
|
||||||
)
|
)
|
||||||
|
|
||||||
if [[ " ${NO_INSTALL_FROM_API_COMMANDS[*]} " == *" ${HOMEBREW_COMMAND} "* ]]
|
if check-array-membership "${HOMEBREW_COMMAND}" "${NO_INSTALL_FROM_API_COMMANDS[@]}"
|
||||||
then
|
then
|
||||||
export HOMEBREW_NO_INSTALL_FROM_API=1
|
export HOMEBREW_NO_INSTALL_FROM_API=1
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user