From 2498d99a143d0e50e92a0aa60316d47c9ea83edc Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 5 Sep 2016 02:19:40 +0100 Subject: Implement opoo in bash --- Library/Homebrew/brew.sh | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index 1651e8262..fd1accef5 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -1,20 +1,35 @@ HOMEBREW_VERSION="0.9.9" -onoe() { - if [[ -t 2 ]] # check whether stderr is a tty. +o() { + if [[ $# -eq 0 ]] then - echo -ne "\033[4;31mError\033[0m: " >&2 # highlight Error with underline and red color + /bin/cat else - echo -n "Error: " >&2 + echo "$*" fi - if [[ $# -eq 0 ]] +} + +highlight() { + if [[ -t 1 ]] # check whether stdout is a tty. then - /bin/cat >&2 + echo -ne "\033[4;$1m$2\033[0m" else - echo "$*" >&2 + echo -n "$2" fi } +opoo() { + highlight 33 Warning >&2 # yellow + echo -n ": " >&2 + o "$@" >&2 +} + +onoe() { + highlight 31 Error >&2 # red + echo -n ": " >&2 + o "$@" >&2 +} + odie() { onoe "$@" exit 1 -- cgit v1.2.3 From 07a00c234c2f0ed3387fc6508c2da21866f1e222 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 5 Sep 2016 11:20:19 +0100 Subject: Warn when changing branch on update Closes #877 --- Library/Homebrew/cmd/update.sh | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index c0658aa4c..9a9567101 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -242,6 +242,15 @@ EOS INITIAL_BRANCH="$(git symbolic-ref --short HEAD 2>/dev/null)" if [[ "$INITIAL_BRANCH" != "$UPSTREAM_BRANCH" && -n "$INITIAL_BRANCH" ]] then + + if [[ -z "$HOMEBREW_DEVELOPER" ]] + then + opoo </dev/null -- cgit v1.2.3 From 04ebd0af33eb101582bf0944e31140ee9799b4cf Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 5 Sep 2016 22:18:24 +0100 Subject: Adjust branch change message --- Library/Homebrew/cmd/update.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index 9a9567101..ed51444c5 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -245,10 +245,9 @@ EOS if [[ -z "$HOMEBREW_DEVELOPER" ]] then - opoo <&2 # highlight Error with underline and red color else - echo "$*" + echo -n "Error: " >&2 fi -} - -highlight() { - if [[ -t 1 ]] # check whether stdout is a tty. + if [[ $# -eq 0 ]] then - echo -ne "\033[4;$1m$2\033[0m" + /bin/cat >&2 else - echo -n "$2" + echo "$*" >&2 fi } -opoo() { - highlight 33 Warning >&2 # yellow - echo -n ": " >&2 - o "$@" >&2 -} - -onoe() { - highlight 31 Error >&2 # red - echo -n ": " >&2 - o "$@" >&2 -} - odie() { onoe "$@" exit 1 -- cgit v1.2.3