Skip to content

Instantly share code, notes, and snippets.

@RyanPossible
Created September 9, 2016 14:03

Revisions

  1. RyanPossible created this gist Sep 9, 2016.
    31 changes: 31 additions & 0 deletions good_morning.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    #!/bin/bash

    toUpgrade=('git' 'node' 'wget' 'openssl')

    array_contains () {
    local array="$1[@]"
    local seeking=$2
    local in=1
    for element in "${!array}"; do
    if [[ $element == $seeking ]]; then
    in=0
    break
    fi
    done
    return $in
    }

    echo "Good Morning Mr. Schumacher!"
    echo "Updating Brew:"

    brew update

    OUTDATED="$(brew outdated)"

    IFS=' ' read -ra FORMULAES <<< "$OUTDATED"

    for FORMULAE in "${FORMULAES[@]}"; do
    array_contains toUpgrade "$FORMULAE" && echo "$(brew upgrade $FORMULAE)"
    done

    echo "Have a good day Mr. Schumacher!"