Merge pull request #1413 from zmwangx/update-preinstall-message

brew.sh: display message when auto update runs for too long
This commit is contained in:
Mike McQuaid 2016-11-05 09:55:37 -04:00 committed by GitHub
commit 3cef6a3a78

View File

@ -296,6 +296,13 @@ source "$HOMEBREW_LIBRARY/Homebrew/utils/analytics.sh"
setup-analytics
report-analytics-screenview-command
# Let user know we're still updating Homebrew if brew update --preinstall
# exceeds 3 seconds.
update-preinstall-timer() {
sleep 3
echo 'Updating Homebrew...' >&2
}
update-preinstall() {
[[ -z "$HOMEBREW_HELP" ]] || return
[[ -z "$HOMEBREW_NO_AUTO_UPDATE" ]] || return
@ -306,7 +313,19 @@ update-preinstall() {
if [[ "$HOMEBREW_COMMAND" = "install" || "$HOMEBREW_COMMAND" = "upgrade" || "$HOMEBREW_COMMAND" = "tap" ]]
then
if [[ -z "$HOMEBREW_VERBOSE" ]]
then
update-preinstall-timer &
timer_pid=$!
fi
brew update --preinstall
if [[ -n "$timer_pid" ]]
then
kill "$timer_pid" 2>/dev/null
wait "$timer_pid" 2>/dev/null
fi
fi
# If brew update --preinstall did a migration then export the new locations.