2 # ax-common.sh -- Common Functions for Shell Scripts
3 # Copyright (c)2013-2015 Alexander Barton (alex@barton.de)
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
13 # Display a colored message.
14 # $1 Level: -=title, 0=ok, 1=warning, 2=error.
15 # $2 Word(s) to highlight.
16 # $3-n Remaining word(s). [optional]
19 "0") c="32"; shift; ;; # green
20 "1") c="33"; shift; ;; # yellow
21 "2") c="31"; shift; ;; # red
22 "-") c="1"; shift; ;; # bold
25 # print colored word(s):
30 # print remaining word(s) and trailing newline:
34 # Display a colored message.
35 # $1 Level, see ax_msg1 function.
36 # $2-n Word(s) to highlight.
43 # Abort the script with an error message and exit code 1.
44 # $1 Error message [optional]. Will be formatted as "Error: %s Aborting!".
45 # if no error message is given, "Aborting!" will be printed.
48 && ax_msg 2 "Error: $* Aborting!" \
49 || ax_msg 2 "Aborting!"