|
42 | 42 |
|
43 | 43 | umask 0022 |
44 | 44 |
|
| 45 | +# Message common function |
| 46 | +# msg_common [type] [-n] [string] |
| 47 | +msg_common(){ |
| 48 | + local _msg_opts=("-a" "build.sh") _type="${1}" |
| 49 | + shift 1 |
| 50 | + [[ "${1}" = "-n" ]] && _msg_opts+=("-o" "-n") && shift 1 |
| 51 | + [[ "${msgdebug}" = true ]] && _msg_opts+=("-x") |
| 52 | + [[ "${nocolor}" = true ]] && _msg_opts+=("-n") |
| 53 | + _msg_opts+=("${_type}" "${@}") |
| 54 | + "${tools_dir}/msg.sh" "${_msg_opts[@]}" |
| 55 | +} |
| 56 | + |
45 | 57 | # Show an INFO message |
46 | 58 | # ${1}: message string |
47 | 59 | msg_info() { |
48 | | - local _msg_opts="-a build.sh" |
49 | | - if [[ "${1}" = "-n" ]]; then |
50 | | - _msg_opts="${_msg_opts} -o -n" |
51 | | - shift 1 |
52 | | - fi |
53 | | - [[ "${msgdebug}" = true ]] && _msg_opts="${_msg_opts} -x" |
54 | | - [[ "${nocolor}" = true ]] && _msg_opts="${_msg_opts} -n" |
55 | | - "${tools_dir}/msg.sh" ${_msg_opts} info "${1}" |
| 60 | + msg_common info "${@}" |
56 | 61 | } |
57 | 62 |
|
58 | 63 | # Show an Warning message |
59 | 64 | # ${1}: message string |
60 | 65 | msg_warn() { |
61 | | - local _msg_opts="-a build.sh" |
62 | | - if [[ "${1}" = "-n" ]]; then |
63 | | - _msg_opts="${_msg_opts} -o -n" |
64 | | - shift 1 |
65 | | - fi |
66 | | - [[ "${msgdebug}" = true ]] && _msg_opts="${_msg_opts} -x" |
67 | | - [[ "${nocolor}" = true ]] && _msg_opts="${_msg_opts} -n" |
68 | | - "${tools_dir}/msg.sh" ${_msg_opts} warn "${1}" |
| 66 | + msg_common warn "${@}" |
69 | 67 | } |
70 | 68 |
|
71 | 69 | # Show an debug message |
72 | 70 | # ${1}: message string |
73 | 71 | msg_debug() { |
74 | 72 | if [[ "${debug}" = true ]]; then |
75 | | - local _msg_opts="-a build.sh" |
76 | | - if [[ "${1}" = "-n" ]]; then |
77 | | - _msg_opts="${_msg_opts} -o -n" |
78 | | - shift 1 |
79 | | - fi |
80 | | - [[ "${msgdebug}" = true ]] && _msg_opts="${_msg_opts} -x" |
81 | | - [[ "${nocolor}" = true ]] && _msg_opts="${_msg_opts} -n" |
82 | | - "${tools_dir}/msg.sh" ${_msg_opts} debug "${1}" |
| 73 | + msg_common debug "${@}" |
83 | 74 | fi |
84 | 75 | } |
85 | 76 |
|
86 | 77 | # Show an ERROR message then exit with status |
87 | 78 | # ${1}: message string |
88 | 79 | # ${2}: exit code number (with 0 does not exit) |
89 | 80 | msg_error() { |
90 | | - local _msg_opts="-a build.sh" |
91 | | - if [[ "${1}" = "-n" ]]; then |
92 | | - _msg_opts="${_msg_opts} -o -n" |
93 | | - shift 1 |
94 | | - fi |
95 | | - [[ "${msgdebug}" = true ]] && _msg_opts="${_msg_opts} -x" |
96 | | - [[ "${nocolor}" = true ]] && _msg_opts="${_msg_opts} -n" |
97 | | - "${tools_dir}/msg.sh" ${_msg_opts} error "${1}" |
| 81 | + msg_common error "${@}" |
98 | 82 | if [[ -n "${2:-}" ]]; then |
99 | | - exit ${2} |
| 83 | + exit "${2}" |
100 | 84 | fi |
101 | 85 | } |
102 | 86 |
|
|
0 commit comments