|
|
@ -13,7 +13,7 @@ declare -r HELP_MSG="Usage: $SCRIPT_NAME [OPTION]... [ARG]...
|
|
|
|
|
|
|
|
|
|
|
|
#=== FUNCTIONS ================================================================#
|
|
|
|
#=== FUNCTIONS ================================================================#
|
|
|
|
|
|
|
|
|
|
|
|
## Print colored messages
|
|
|
|
# Print colored messages
|
|
|
|
_cmsg() {
|
|
|
|
_cmsg() {
|
|
|
|
case "$1" in
|
|
|
|
case "$1" in
|
|
|
|
black) COLOR="\033[0;30m" ;;
|
|
|
|
black) COLOR="\033[0;30m" ;;
|
|
|
@ -37,13 +37,13 @@ _cmsg() {
|
|
|
|
printf "${COLOR}${2}\33[0m\n"
|
|
|
|
printf "${COLOR}${2}\33[0m\n"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
## exit the shell(default status code: 1) after printing the message to stderr
|
|
|
|
# exit the shell(default status code: 1) after printing the message to stderr
|
|
|
|
_bail() {
|
|
|
|
_bail() {
|
|
|
|
echo -ne "$1" >&2
|
|
|
|
>&2 echo -ne "$1"
|
|
|
|
exit ${2-1}
|
|
|
|
exit ${2-1}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
## print the usage and exit the shell(default status code: 2)
|
|
|
|
# print the usage and exit the shell(default status code: 2)
|
|
|
|
_usage() {
|
|
|
|
_usage() {
|
|
|
|
local status=2
|
|
|
|
local status=2
|
|
|
|
if [[ "$1" =~ ^[0-9]+$ ]]; then
|
|
|
|
if [[ "$1" =~ ^[0-9]+$ ]]; then
|
|
|
@ -53,10 +53,11 @@ _usage() {
|
|
|
|
_bail "${1}$HELP_MSG" $status
|
|
|
|
_bail "${1}$HELP_MSG" $status
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# print fancy error message
|
|
|
|
_failure() {
|
|
|
|
_failure() {
|
|
|
|
local lineno=$1
|
|
|
|
local lineno=$1
|
|
|
|
local msg=$2
|
|
|
|
local msg=$2
|
|
|
|
echo "Failed at $lineno: $msg"
|
|
|
|
>&2 echo "Failed at $lineno: $msg"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#=== SET ENVIRONMENT AND EXIT CONDITIONS ======================================#
|
|
|
|
#=== SET ENVIRONMENT AND EXIT CONDITIONS ======================================#
|
|
|
@ -91,7 +92,7 @@ done
|
|
|
|
shift $OPTIND
|
|
|
|
shift $OPTIND
|
|
|
|
[[ "$#" -lt 1 ]] && usage "Too few arguments\n"
|
|
|
|
[[ "$#" -lt 1 ]] && usage "Too few arguments\n"
|
|
|
|
|
|
|
|
|
|
|
|
#=== MAIN CODE BELOW ==========================================================#
|
|
|
|
#=== MAIN CODE GOES HERE ======================================================#
|
|
|
|
|
|
|
|
|
|
|
|
echo "Start!"
|
|
|
|
echo "Start!"
|
|
|
|
|
|
|
|
|
|
|
|