mirror of
https://github.com/natelandau/shell-scripting-templates.git
synced 2025-11-10 14:13:45 -05:00
updates
This commit is contained in:
2
scriptTemplate.sh
Executable file → Normal file
2
scriptTemplate.sh
Executable file → Normal file
@@ -55,7 +55,7 @@ function trapCleanup() {
|
|||||||
if is_dir "${tmpDir}"; then
|
if is_dir "${tmpDir}"; then
|
||||||
rm -r "${tmpDir}"
|
rm -r "${tmpDir}"
|
||||||
fi
|
fi
|
||||||
die "Exit trapped." # Edit this if you like.
|
die "Exit trapped. In function: '${FUNCNAME[*]}'"
|
||||||
}
|
}
|
||||||
|
|
||||||
# safeExit
|
# safeExit
|
||||||
|
|||||||
35
simpleScriptTemplate.sh
Executable file → Normal file
35
simpleScriptTemplate.sh
Executable file → Normal file
@@ -15,9 +15,6 @@ function mainScript() {
|
|||||||
echo -n
|
echo -n
|
||||||
}
|
}
|
||||||
|
|
||||||
## SET SCRIPTNAME VARIABLE ##
|
|
||||||
scriptName=$(basename "$0")
|
|
||||||
|
|
||||||
function trapCleanup() {
|
function trapCleanup() {
|
||||||
# trapCleanup Function
|
# trapCleanup Function
|
||||||
# -----------------------------------
|
# -----------------------------------
|
||||||
@@ -29,7 +26,7 @@ function trapCleanup() {
|
|||||||
if [ -d "${tmpDir}" ] ; then
|
if [ -d "${tmpDir}" ] ; then
|
||||||
rm -r "${tmpDir}"
|
rm -r "${tmpDir}"
|
||||||
fi
|
fi
|
||||||
die "Exit trapped."
|
die "Exit trapped. In function: '${FUNCNAME[*]}'"
|
||||||
}
|
}
|
||||||
|
|
||||||
function safeExit() {
|
function safeExit() {
|
||||||
@@ -46,11 +43,11 @@ function safeExit() {
|
|||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Set Base Variables
|
||||||
|
# ----------------------
|
||||||
|
scriptName=$(basename "$0")
|
||||||
|
|
||||||
# Set Flags
|
# Set Flags
|
||||||
# -----------------------------------
|
|
||||||
# Flags which can be overridden by user input.
|
|
||||||
# Default values are below
|
|
||||||
# -----------------------------------
|
|
||||||
quiet=false
|
quiet=false
|
||||||
printLog=false
|
printLog=false
|
||||||
verbose=false
|
verbose=false
|
||||||
@@ -59,6 +56,16 @@ strict=false
|
|||||||
debug=false
|
debug=false
|
||||||
args=()
|
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
|
# Set Temp Directory
|
||||||
# -----------------------------------
|
# -----------------------------------
|
||||||
# Create temp directory with three random numbers and the process ID
|
# Create temp directory with three random numbers and the process ID
|
||||||
@@ -173,22 +180,12 @@ args+=("$@")
|
|||||||
# Example usage: success "sometext"
|
# 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() {
|
function _alert() {
|
||||||
if [ "${1}" = "error" ]; then local color="${bold}${red}"; fi
|
if [ "${1}" = "error" ]; then local color="${bold}${red}"; fi
|
||||||
if [ "${1}" = "warning" ]; then local color="${red}"; fi
|
if [ "${1}" = "warning" ]; then local color="${red}"; fi
|
||||||
if [ "${1}" = "success" ]; then local color="${green}"; fi
|
if [ "${1}" = "success" ]; then local color="${green}"; fi
|
||||||
if [ "${1}" = "debug" ]; then local color="${purple}"; 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}" = "input" ]; then local color="${bold}"; fi
|
||||||
if [ "${1}" = "info" ] || [ "${1}" = "notice" ]; then local color=""; fi
|
if [ "${1}" = "info" ] || [ "${1}" = "notice" ]; then local color=""; fi
|
||||||
# Don't use colors on pipes or non-recognized terminals
|
# Don't use colors on pipes or non-recognized terminals
|
||||||
|
|||||||
Reference in New Issue
Block a user