-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
message_utils.sh
executable file
·69 lines (57 loc) · 1.09 KB
/
message_utils.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!zsh
# Terminal colors
RED=`tput setaf 1`
GREEN=`tput setaf 2`
YELLOW=`tput setaf 3`
BLUE=`tput setaf 4`
MAGENTA=`tput setaf 5`
CYAN=`tput setaf 6`
WHITE=`tput setaf 7`
RESET=`tput sgr0`
progress_success() (
MESSAGE="==== ${1} ===="
echo ${MESSAGE}
echo "${GREEN}${MESSAGE}${RESET}" >&3
)
progress_error() (
MESSAGE="** ${1} **"
echo ${MESSAGE}
echo "${RED}${MESSAGE}${RESET}" >&3
)
progress_section() (
MESSAGE="=== ${1} ==="
echo ${MESSAGE}
echo "${MAGENTA}${MESSAGE}${RESET}" >&3
)
progress_subsection() (
MESSAGE="== ${1} =="
echo ${MESSAGE}
echo "${CYAN}${MESSAGE}${RESET}" >&3
)
progress_item() (
MESSAGE="= ${1} ="
echo ${MESSAGE}
echo "${BLUE}${MESSAGE}${RESET}" >&3
)
note() (
MESSAGE="* ${1}"
echo ${MESSAGE}
echo "${YELLOW}${MESSAGE}${RESET}" >&3
)
export CONTEXT=top
TRAPZERR() {
if [[ ${CONTEXT} == "top" ]]
then
progress_error "Build error."
echo "Log tail:" >&3
tail -n 10 ${BUILD_LOG} >&3
fi
return $(( 128 + $1 ))
}
TRAPINT() {
if [[ ${CONTEXT} == "top" ]]
then
progress_error "Build stopped."
fi
return $(( 128 + $1 ))
}