From abe98e6cbf35f6899ada612157bfb7aecf7bc1cc Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Thu, 27 Jun 2024 22:10:24 +0200 Subject: [PATCH] Improve readability and fix quoting in fake netcat No functional changes. --- tests/bin/nc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/bin/nc b/tests/bin/nc index d74e918..40a24fb 100755 --- a/tests/bin/nc +++ b/tests/bin/nc @@ -6,11 +6,17 @@ local_port=1024 case "$input" in -*) echo "nc: bad input: \$input" >&2; exit 1;; esac -while [ ! -z $1 ]; do - case $1 in +while [ ! -z "$1" ]; do + case "$1" in -w) shift 2;; - -p) local_port=$2; shift 2;; - *) if [ -z $host ]; then host=$1; elif [ -z $port ]; then port=$1; fi; shift 1;; + -p) local_port="$2"; shift 2;; + *) if [ -z "$host" ]; then + host="$1" + elif [ -z "$port" ]; then + port="$1"; + fi + shift 1 + ;; esac done