aboutsummaryrefslogtreecommitdiffstats
path: root/Library/brew.sh
diff options
context:
space:
mode:
authorMike McQuaid2016-04-11 09:31:50 +0100
committerMike McQuaid2016-04-11 09:31:50 +0100
commit4a7cd160c31969b79979ae9bd20afcf82d9513c0 (patch)
tree37f16512cb0f4fee1237e72310722c67e99af69c /Library/brew.sh
parent0382134cf87321166fb8f03223e21b1d242ad7cb (diff)
downloadbrew-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.sh17
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