aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorAlyssa Ross2016-09-05 02:19:40 +0100
committerAlyssa Ross2016-09-05 10:33:50 +0100
commit2498d99a143d0e50e92a0aa60316d47c9ea83edc (patch)
tree8baa89dcbb6349715509b2f815fec38bf09a0658 /Library
parentefd29ebacaf6352e79c3e3a4c45b9e85c02c8a77 (diff)
downloadbrew-2498d99a143d0e50e92a0aa60316d47c9ea83edc.tar.bz2
Implement opoo in bash
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/brew.sh29
1 files changed, 22 insertions, 7 deletions
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