From: Paul Hänsch Date: Wed, 5 Aug 2020 14:17:00 +0000 (+0200) Subject: Debug function based on environment X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=8b6ad0ae9012142caa5b7048c85a9488aa341252;p=lobster Debug function based on environment --- 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"