X-Git-Url: http://git.plutz.net/?p=cgilite;a=blobdiff_plain;f=index.cgi;h=b407fc17ea0dcf6d556dba7b5ad5df5eb91189b2;hp=6359a0ae353e009e9dcbfc8425c52b1244bf6112;hb=9b62da2cc5552e018fe8c48360c770446a9a6b55;hpb=d4c4b43f0c0a3632998892da7bad8a18e687b0e8 diff --git a/index.cgi b/index.cgi index 6359a0a..b407fc1 100755 --- a/index.cgi +++ b/index.cgi @@ -17,7 +17,9 @@ # You should have received a copy of the GNU Affero General Public License # along with shcgi. If not, see . -export LC_ALL=C +export LC_ALL=C LANG=C +DBG_ENABLED=false +DBG_FILE=/dev/stderr # this program is supposed to be symlinked into a http root directory # we will use the http root as object storage (data directory) and call sub @@ -28,16 +30,24 @@ real="$(readlink -f $call)" _DATA="$(dirname "$call")" #storage directory _EXEC="${real%/shcgi/index.cgi}" #execution directory +# put debug options in the local.opts file +[ -r "$_DATA/local.opts" ] && . "$_DATA/local.opts" + # basic functions -die() { - echo "$@" >&2 - exit 1 +debug() { #change to false to disable debugging + if [ "$DBG_ENABLED" = true -a -n "$*" ]; then + printf '%s\n' "$*" >>"$DBG_FILE" + elif [ "$DBG_ENABLED" = true -a -z "$*" ]; then + tee -a "$DBG_FILE" + elif [ -z "$*" ]; then + cat + fi } -debug() { #change to false to disable debugging - #true && echo "$*" >>debug - true && [ -n "$*" ] && echo -E "$*" >>/dev/stderr - true && [ -z "$*" ] && tee /dev/stderr +die() { + debug FATAL: "$*" + printf '%s\n' "$*" >&2 + exit 1 } data_dirs(){ @@ -64,10 +74,8 @@ cgi_get [ -x "$_EXEC/constants.sh" ] && . "$_EXEC/constants.sh" -if [ -n "$_GET[\"action\"]" ]; then +if [ -n "${_GET[action]}" ]; then . "$_EXEC/shcgi/action.sh" -elif [ -n "$_GET[\"export\"]" ]; then - . "$_EXEC/shcgi/export.sh" else . "$_EXEC/shcgi/page.sh" fi