diff --git a/scriptTemplate.sh b/scriptTemplate.sh old mode 100755 new mode 100644 index ca9c84f..3df8fa5 --- a/scriptTemplate.sh +++ b/scriptTemplate.sh @@ -55,7 +55,7 @@ function trapCleanup() { if is_dir "${tmpDir}"; then rm -r "${tmpDir}" fi - die "Exit trapped." # Edit this if you like. + die "Exit trapped. In function: '${FUNCNAME[*]}'" } # safeExit diff --git a/simpleScriptTemplate.sh b/simpleScriptTemplate.sh old mode 100755 new mode 100644 index b220019..30b04d2 --- a/simpleScriptTemplate.sh +++ b/simpleScriptTemplate.sh @@ -15,9 +15,6 @@ function mainScript() { echo -n } -## SET SCRIPTNAME VARIABLE ## -scriptName=$(basename "$0") - function trapCleanup() { # trapCleanup Function # ----------------------------------- @@ -29,7 +26,7 @@ function trapCleanup() { if [ -d "${tmpDir}" ] ; then rm -r "${tmpDir}" fi - die "Exit trapped." + die "Exit trapped. In function: '${FUNCNAME[*]}'" } function safeExit() { @@ -46,11 +43,11 @@ function safeExit() { exit } +# Set Base Variables +# ---------------------- +scriptName=$(basename "$0") + # Set Flags -# ----------------------------------- -# Flags which can be overridden by user input. -# Default values are below -# ----------------------------------- quiet=false printLog=false verbose=false @@ -59,6 +56,16 @@ strict=false debug=false args=() +# Set Colors +bold=$(tput bold) +reset=$(tput sgr0) +purple=$(tput setaf 171) +red=$(tput setaf 1) +green=$(tput setaf 76) +tan=$(tput setaf 3) +blue=$(tput setaf 38) +underline=$(tput sgr 0 1) + # Set Temp Directory # ----------------------------------- # Create temp directory with three random numbers and the process ID @@ -173,22 +180,12 @@ args+=("$@") # Example usage: success "sometext" #------------------------------------------------------ -# Set Colors -bold=$(tput bold) -reset=$(tput sgr0) -purple=$(tput setaf 171) -red=$(tput setaf 1) -green=$(tput setaf 76) -tan=$(tput setaf 3) -blue=$(tput setaf 38) -underline=$(tput sgr 0 1) - function _alert() { if [ "${1}" = "error" ]; then local color="${bold}${red}"; fi if [ "${1}" = "warning" ]; then local color="${red}"; fi if [ "${1}" = "success" ]; then local color="${green}"; fi if [ "${1}" = "debug" ]; then local color="${purple}"; fi - if [ "${1}" = "header" ]; then local color="${bold}""${tan}"; fi + if [ "${1}" = "header" ]; then local color="${bold}${tan}"; fi if [ "${1}" = "input" ]; then local color="${bold}"; fi if [ "${1}" = "info" ] || [ "${1}" = "notice" ]; then local color=""; fi # Don't use colors on pipes or non-recognized terminals