diff --git a/bash/templates/template.sh b/bash/templates/template.sh index 72e3921..702bb18 100755 --- a/bash/templates/template.sh +++ b/bash/templates/template.sh @@ -13,7 +13,7 @@ declare -r HELP_MSG="Usage: $SCRIPT_NAME [OPTION]... [ARG]... #=== FUNCTIONS ================================================================# -## Print colored messages +# Print colored messages _cmsg() { case "$1" in black) COLOR="\033[0;30m" ;; @@ -37,13 +37,13 @@ _cmsg() { 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() { - echo -ne "$1" >&2 + >&2 echo -ne "$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() { local status=2 if [[ "$1" =~ ^[0-9]+$ ]]; then @@ -53,10 +53,11 @@ _usage() { _bail "${1}$HELP_MSG" $status } +# print fancy error message _failure() { local lineno=$1 local msg=$2 - echo "Failed at $lineno: $msg" + >&2 echo "Failed at $lineno: $msg" } #=== SET ENVIRONMENT AND EXIT CONDITIONS ======================================# @@ -91,7 +92,7 @@ done shift $OPTIND [[ "$#" -lt 1 ]] && usage "Too few arguments\n" -#=== MAIN CODE BELOW ==========================================================# +#=== MAIN CODE GOES HERE ======================================================# echo "Start!"