Created
June 17, 2010 02:50
-
-
Save craSH/441624 to your computer and use it in GitHub Desktop.
upgrade brews a-la 'apt-get dist-upgrade'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Very simple script that updates your brew formula repo and | |
# then upgrades all installed and outdated formulae | |
# Run with -y to upgrade formulae automatically | |
# | |
# Update the repo | |
brew update | |
# List of outdated formulae | |
outdated=$(brew outdated | awk '{print $1}') | |
# Function that actually upgrades the packages | |
function upgradebrews() { | |
for i in $(brew outdated | awk '{print $1}'); do | |
echo "installing $i" | |
brew install $i || exit 1 | |
done | |
} | |
# Update any out of date ones | |
if [ -z "$outdated" ]; then | |
echo "All installed formulae are up to date, nothing to do!" | |
exit 0 | |
else | |
echo "About to upgrade the following formulae: $outdated" | |
if [ "$1" != "-y" ]; then | |
echo -n 'Proceed with upgrade? (y/n): ' | |
read proceed | |
if [ "$proceed" == "y" ]; then | |
echo "Upgrading..." | |
upgradebrews | |
else | |
echo "Aborting..." | |
exit 0 | |
fi | |
else | |
upgradebrews | |
fi | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment