]> git.plutz.net Git - cgilite/commitdiff
add universal --debug option
authorPaul Hänsch <paul@plutz.net>
Wed, 14 Jan 2026 04:39:36 +0000 (05:39 +0100)
committerPaul Hänsch <paul@plutz.net>
Wed, 14 Jan 2026 04:39:36 +0000 (05:39 +0100)
cgilite.sh

index fc7953b93d597242f3c5c86c4608a06afbcf526e..5e4ebbb750c3f29856cb761d3aad7d8578bc233c 100755 (executable)
@@ -40,6 +40,7 @@ for cgilite_arg in "$@"; do case $cgilite_arg in
   --exec=*) _EXEC="${cgilite_arg#*=}";;
   --data=*) _DATA="${cgilite_arg#*=}";;
   --base=*) _BASE="${cgilite_arg#*=}";;
+ --debug=*) DEBUG="${cgilite_arg#*=}";;
 esac; done
 unset cgilite_arg
 
@@ -48,6 +49,7 @@ _DATA="${_DATA:-${PWD:-.}}"
 _EXEC="${_EXEC%/}" _DATA="${_DATA%/}" _BASE="${_BASE%/}"
 
 export _EXEC _DATA _BASE
+[ -n "$DEBUG" ] && exec 2>"${DEBUG}"
 
 # Carriage Return and Line Break characters for convenience
 CR="\r"
@@ -207,7 +209,7 @@ fi
 
 PATH_INFO="$(PATH "/${PATH_INFO#${_BASE}}")"
 
-debug(){ [ $# -gt 0 ] && printf '%s\n' "$@" >&2 || tee -a /dev/stderr; }
+debug(){ [ $# -gt 0 ] && printf '%s\n' "$@" >&2 || tee -a "${DEBUG:-/dev/stderr}"; }
 [ "${DEBUG+x}" ] && env >&2
 
 # general helper functions, see GET, POST, and REF below