From 8b6ad0ae9012142caa5b7048c85a9488aa341252 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Wed, 5 Aug 2020 16:17:00 +0200 Subject: [PATCH] Debug function based on environment --- index.cgi | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/index.cgi b/index.cgi index 9d9a3e7..9d7d18f 100755 --- a/index.cgi +++ b/index.cgi @@ -9,15 +9,16 @@ esac; done [ -z "${_EXEC%/}" ] && _EXEC="$(realpath "${0%/*}")" || _EXEC="${_EXEC%/}" [ -z "${_DATA%/}" ] && _DATA=. || _DATA="${_DATA%/}" -# debug() { -# local dbg=/dev/stderr -# if [ "$#" -gt 0 ]; then -# printf '%s\n' "$@" >>"$dbg" -# else -# tee -a "$dbg" -# fi -# } -debug() { [ "$#" -gt 0 ] && : || cat; } +debug() { + local dbg=/dev/stderr + if [ ! "$DEBUG" ]; then + [ "$#" -gt 0 ] && : || cat; + elif [ "$#" -gt 0 ]; then + printf '%s\n' "$@" >>"$dbg" + else + tee -a "$dbg" + fi +} . "$_EXEC/cgilite/cgilite.sh" . "$_EXEC/cgilite/session.sh" -- 2.39.2