From b37aed0edcfabe3d4c8550fba3d0601053dd3483 Mon Sep 17 00:00:00 2001 From: Alex Flores Date: Tue, 23 Jan 2018 14:12:30 -0500 Subject: [PATCH] fixes debug extention (#312) - resolve sytax errors with variable declarations - resolve misuse of command substition / variabl dereferencing - internal functions were being called before being declared - remove superfluous file existence checks --- payloads/extensions/debug.sh | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/payloads/extensions/debug.sh b/payloads/extensions/debug.sh index e58b0b66..f575dfe6 100644 --- a/payloads/extensions/debug.sh +++ b/payloads/extensions/debug.sh @@ -11,30 +11,17 @@ ################################################################################ function DEBUG() { - session = $1 - message = $2 - - init_debug - debug_log + session=$1 + message=$2 timestamp () { echo "$(date +"%Y-%m-%d_%H-%M-%S")" } - init_debug () { - DEBUG_FILE="/root/udisk/debug/$(session).txt" - if [ ! -d "/root/udisk/debug/" ]; then - mkdir /root/udisk/debug/ - fi - if [ ! -f "/root/udisk/debug/${DEBUG_FILE}" ]; then - touch "${DEBUG_FILE}" - echo "$(timestamp): DEBUG STARTED" >> "${DEBUG_FILE}" - fi - } - - debug_log () { - echo "$(timestamp): $(message)" >> "${DEBUG_FILE}" - } + mkdir -p /root/udisk/debug/ + debug_file="/root/udisk/debug/${session}.txt" + [[ -f "${debug_file}" ]] || echo "$(timestamp): DEBUG STARTED" >> "${debug_file}" + echo "$(timestamp): ${message}" >> ${debug_file} } export -f DEBUG