summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2020-09-15 20:57:00 +0200
committertv <tv@krebsco.de>2020-09-15 20:57:21 +0200
commit2922721e2d3de6ff959d352e32ff8f4f9d8cbe7d (patch)
treebdb60d816e9d6c29a82d38e24af98c3ad5dc5f4b
parenta20725518fead2694f62fa2a7ae5e08ece7915bf (diff)
add --verbose flagv1.2.41.2.4
-rwxr-xr-xhtgen7
1 files changed, 6 insertions, 1 deletions
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