Enhanced DEBUG output for command line options

This commit is contained in:
upuv 2018-06-03 15:49:19 +10:00
parent 8327f15ac2
commit de6d5db3f2

View File

@ -63,9 +63,43 @@ if [ "$#" -eq 0 ]; then
exit 1 exit 1
fi fi
set -o errexit -o noclobber -o nounset -o pipefail
# ========================================================================
# Utility Functions
# -----
# debug
debug() {
if [ $DEBUG == 1 ] ; then
echo "$(date "+%F %T%z") DEBUG ${1}"
fi
}
# -----
# debug dump contents of a file to STDOUT
debug_file() {
if [ $DEBUG == 1 ] ; then
echo "$(date "+%F %T%z") DEBUG"
echo "================================================================================"
cat "${1}"
echo "================================================================================"
fi
}
# -----
# log
log() {
echo "$(date "+%F %T%z") ${1}"
}
# -----
# Print out what we have already after command line processing.
debug "Command line options as set:$(printf '\n%-18s: %s\n%-18s: %s\n%-18s: %s\n%-18s: %s\n%-18s: %s\n%-18s: %s\n%-18s: %s' codec "${codec}" extension "${extension}" mode "${mode}" container "${container}" targetdir "${targetdir}" completedir "${completedir}" auth_code "${auth_code}")"
# ======================================================================== # ========================================================================
# Variable validation # Variable validation
set -o errexit -o noclobber -o nounset -o pipefail
# ----- # -----
# Detect which annoying version fo grep we have # Detect which annoying version fo grep we have
@ -127,34 +161,6 @@ if [[ "x${completedir}" != "x" ]]; then
fi fi
fi fi
# ========================================================================
# Utility Functions
# -----
# debug
debug() {
if [ $DEBUG == 1 ] ; then
echo "$(date "+%F %T%z") DEBUG ${1}"
fi
}
# -----
# debug dump contents of a file to STDOUT
debug_file() {
if [ $DEBUG == 1 ] ; then
echo "$(date "+%F %T%z") DEBUG"
echo "================================================================================"
cat "${1}"
echo "================================================================================"
fi
}
# -----
# log
log() {
echo "$(date "+%F %T%z") ${1}"
}
# ----- # -----
# Clean up if someone hits ^c # Clean up if someone hits ^c
trap 'rm -r -f "${working_directory}"' EXIT trap 'rm -r -f "${working_directory}"' EXIT