From 2922721e2d3de6ff959d352e32ff8f4f9d8cbe7d Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 15 Sep 2020 20:57:00 +0200 Subject: add --verbose flag --- htgen | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htgen b/htgen index ba6976b..23e3b2a 100755 --- a/htgen +++ b/htgen @@ -6,9 +6,11 @@ Server=htgen ## parse arguments {{{ action=handle_request +verbose=${HTGEN_VERBOSE-false} while test $# -gt 0; do case $1 in) --serve) action=serve; shift; continue;; + --verbose) verbose=true; shift; continue;; *) echo "$0: error: bad argument: $1" >&2; exit 1;; esac done @@ -22,6 +24,7 @@ case $action in HTGEN_HOST=${HTGEN_HOST-0.0.0.0} HTGEN_PORT=${HTGEN_PORT-42380} HTGEN_SCRIPT=${HTGEN_SCRIPT-:} + HTGEN_VERBOSE=$verbose; export HTGEN_VERBOSE TCPSERVER_OPTS='-c 423 -t 2 -D' echo "#### $Server $HTGEN_HOST:$HTGEN_PORT" >&2 exec tcpserver $TCPSERVER_OPTS "$HTGEN_HOST" "$HTGEN_PORT" "$0" @@ -94,7 +97,9 @@ while read -r line; do k=req_$k v=${line#*:} v=${v## } - printf '%s=%s\n' "$k" "$v" >&2 + if test "$HTGEN_VERBOSE" = true; then + printf '%s=%s\n' "$k" "$v" >&2 + fi export "$k=$v" ;; esac -- cgit v1.2.3