diff options
| author | Mike McQuaid | 2016-04-11 09:31:50 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2016-04-11 09:31:50 +0100 |
| commit | 4a7cd160c31969b79979ae9bd20afcf82d9513c0 (patch) | |
| tree | 37f16512cb0f4fee1237e72310722c67e99af69c /Library/brew.sh | |
| parent | 0382134cf87321166fb8f03223e21b1d242ad7cb (diff) | |
| download | brew-4a7cd160c31969b79979ae9bd20afcf82d9513c0.tar.bz2 | |
Auto-update when running `brew install`/`upgrade`.
Also, slightly tweak the behavior of `brew update` in this case so that
it doesn't print annoying output and still allows the `brew edit` flow
for people with `HOMEBREW_DEVELOPER` set.
Diffstat (limited to 'Library/brew.sh')
| -rw-r--r-- | Library/brew.sh | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/Library/brew.sh b/Library/brew.sh index 7f9d141cf..96ee3bd91 100644 --- a/Library/brew.sh +++ b/Library/brew.sh @@ -230,6 +230,19 @@ then & disown fi +update-preinstall() { + [[ -n "$HOMEBREW_AUTO_UPDATE" ]] || return + [[ -z "$HOMEBREW_NO_AUTO_UPDATE" ]] || return + + if [[ "$HOMEBREW_COMMAND" = "install" || "$HOMEBREW_COMMAND" = "upgrade" ]] + then + # Hide shellcheck complaint: + # shellcheck source=/dev/null + source "$HOMEBREW_LIBRARY/Homebrew/cmd/update.sh" + homebrew-update --preinstall + fi +} + if [[ -n "$HOMEBREW_BASH_COMMAND" ]] then # source rather than executing directly to ensure the entire file is read into @@ -240,9 +253,9 @@ then # Hide shellcheck complaint: # shellcheck source=/dev/null source "$HOMEBREW_BASH_COMMAND" - { "homebrew-$HOMEBREW_COMMAND" "$@"; exit $?; } + { update-preinstall; "homebrew-$HOMEBREW_COMMAND" "$@"; exit $?; } else # Unshift command back into argument list (unless argument list was empty). [[ "$HOMEBREW_ARG_COUNT" -gt 0 ]] && set -- "$HOMEBREW_COMMAND" "$@" - exec "$HOMEBREW_RUBY_PATH" -W0 "$HOMEBREW_LIBRARY/brew.rb" "$@" + { update-preinstall; exec "$HOMEBREW_RUBY_PATH" -W0 "$HOMEBREW_LIBRARY/brew.rb" "$@"; } fi |
