From ad8f4e49e045d06f7a63a40f1f8b6308b49489eb Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Wed, 6 Jan 2016 00:56:47 +0100 Subject: [PATCH] Add "brew run" command Signed-off-by: Alexander Barton --- cmd/brew-run | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 cmd/brew-run diff --git a/cmd/brew-run b/cmd/brew-run new file mode 100755 index 0000000..a7104c9 --- /dev/null +++ b/cmd/brew-run @@ -0,0 +1,38 @@ +#!/bin/sh +# 2016-01-06, alex@barton.de + +# Include "ax-common.sh": +for dir in "$HOME/lib" "$HOME/.ax" /usr/local /opt/ax /usr; do + [ -z "$ax_common_sourced" ] || break + ax_common="${dir}/lib/ax/ax-common.sh" + [ -r "$ax_common" ] && source "$ax_common" +done +if [ -z "$ax_common_sourced" ]; then + function ax_msg() { + echo "$2" + } + function ax_abort() { + ax_msg - "$@" + exit 1 + } +fi +unset dir ax_common ax_common_sourced + +ax_msg - "Updating Homebrew installation ..." +brew update || ax_abort "Update failed!" +echo + +outdated=$( brew outdated --quiet | wc -l | tr -d '\t ' ) +if [ $outdated -gt 0 ]; then + ax_msg - "$outdated formula outdated:" + brew outdated || ax_abort "Failed to list outdated packages!" + echo + brew upgrade --all || ax_abort "Upgrade failed!" + brew linkapps --local || ax_abort "Linking of applications failed!" + + echo + brew cleanup || ax_abort "\"brew cleanup\" failed!" + brew prune || ax_abort "\"brew prune\" failed!" +else + ax_msg - "Nothing outdated." +fi -- 2.39.2