All of lore.kernel.org
 help / color / mirror / Atom feed
* [Openvpn-devel] [L] Change in openvpn[master]: Reformat all shell-scripts with shfmt
       [not found] <gerrit.1784305303000.I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f@gerrit.openvpn.net>
@ 2026-07-17 16:21 ` flichtenheld (Code Review) via Openvpn-devel
  2026-07-22  7:29 ` plaisthos (Code Review) via Openvpn-devel
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: flichtenheld (Code Review) via Openvpn-devel @ 2026-07-17 16:21 UTC (permalink / raw)
  To: plaisthos; +Cc: flichtenheld (Code Review), openvpn-devel


[-- Attachment #1.1: Type: text/plain, Size: 59966 bytes --]

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1793?usp=email

to review the following change.


Change subject: Reformat all shell-scripts with shfmt
......................................................................

Reformat all shell-scripts with shfmt

According to ./dev-tools/reformat-shell.sh.

Change-Id: I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
---
M dev-tools/gen-release-tarballs.sh
M dev-tools/git-pre-commit-format.sh
M dev-tools/run-cppcheck.sh
M dev-tools/update-copyright.sh
M tests/lwip_client_up.sh
M tests/null_client_up.sh
M tests/t_client.sh.in
M tests/t_cltsrv.sh
M tests/t_lpback.sh
M tests/t_net.sh
M tests/t_server_null.sh
M tests/t_server_null_client.sh
M tests/t_server_null_server.sh
M tests/t_server_null_stress.sh
M tests/update_t_client_ips.sh
15 files changed, 447 insertions(+), 468 deletions(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/93/1793/1

diff --git a/dev-tools/gen-release-tarballs.sh b/dev-tools/gen-release-tarballs.sh
index 6071b57..08ae385 100755
--- a/dev-tools/gen-release-tarballs.sh
+++ b/dev-tools/gen-release-tarballs.sh
@@ -21,7 +21,7 @@
 if [ $# -ne 4 ]; then
     echo "Usage: $0 <remote-name> <tag-name> <sign-key> <dest-dir>"
     echo ""
-    echo "   remote-name  -- valid remotes: `git remote | tr \\\n ' '`"
+    echo "   remote-name  -- valid remotes: $(git remote | tr \\n ' ')"
     echo "   tag-name     -- An existing release tag"
     echo "   sign-key     -- PGP key used to sign all files"
     echo "   dest-dir     -- Where to put the complete set of release tarballs"
@@ -48,7 +48,7 @@
 fi

 # Extract the git URL
-giturl="`git remote get-url $arg_remote_name 2>/dev/null`"
+giturl="$(git remote get-url $arg_remote_name 2>/dev/null)"
 if [ $? -ne 0 ]; then
     echo "** ERROR ** Invalid git remote name: $arg_remote_name"
     exit 2
@@ -58,19 +58,17 @@
 echo "test" | gpg -a --clearsign -u "$arg_sign_key" 2>/dev/null 1>/dev/null
 if [ $? -ne 0 ]; then
     echo "** ERROR ** Failed when testing the PGP signing.  Wrong signing key?"
-    exit 2;
+    exit 2
 fi

-
 #
 # Helper functions
 #

-get_filename()
-{
+get_filename() {
     local wildcard="$1"

-    res="`find . -maxdepth 1 -type f -name \"$wildcard\" | head -n1 | cut -d/ -f2-`"
+    res="$(find . -maxdepth 1 -type f -name \"$wildcard\" | head -n1 | cut -d/ -f2-)"
     if [ $? -ne 0 ]; then
         echo "-- 'find' failed."
         exit 5
@@ -82,12 +80,11 @@
     echo "$res"
 }

-copy_files()
-{
+copy_files() {
     local fileext="$1"
     local dest="$2"

-    file="`get_filename openvpn-*.*.*.$fileext`"
+    file="$(get_filename openvpn-*.*.*.$fileext)"
     if [ -z "$file" ]; then
         echo "** ERROR Failed to find source file"
         exit 5
@@ -96,46 +93,45 @@
     cp "$file" "$dest"
     if [ $? -ne 0 ]; then
         echo "** ERROR ** Failed to copy $file to $destdir"
-        exit 3;
+        exit 3
     fi
 }

-sign_file()
-{
+sign_file() {
     local signkey="$1"
     local srchfile="$2"
     local signtype="$3"
-    local file="`get_filename $srchfile`"
+    local file="$(get_filename $srchfile)"

     echo "-- Signing $file ..."
     case "$signtype" in
-        inline)
-            # Have the signature in the same file as the data
-            gpg -a --clearsign -u "$signkey" "$file" 2>/dev/null
-            res=$?
-            if [ $res -eq 0 ]; then
-                rm -f "$file"
-            fi
-            ;;
+    inline)
+        # Have the signature in the same file as the data
+        gpg -a --clearsign -u "$signkey" "$file" 2>/dev/null
+        res=$?
+        if [ $res -eq 0 ]; then
+            rm -f "$file"
+        fi
+        ;;

-        detached)
-            # Have the signature in a separate file
-            gpg -a --detach-sign -u "$signkey" "$file" 2>/dev/null
-            res=$?
-            ;;
+    detached)
+        # Have the signature in a separate file
+        gpg -a --detach-sign -u "$signkey" "$file" 2>/dev/null
+        res=$?
+        ;;

-        *)
-            echo "** ERROR **  Unknown signing type \"$signtype\"."
-            exit 4;
+    *)
+        echo "** ERROR **  Unknown signing type \"$signtype\"."
+        exit 4
+        ;;
     esac

     if [ $res -ne 0 ]; then
         echo "** ERROR **  Failed to sign the file $PWD/$file"
-        exit 4;
+        exit 4
     fi
 }

-
 #
 # Preparations
 #
@@ -143,12 +139,12 @@
 # Create the destination directory, using a sub-dir with the tag-name
 destdir=""
 case "$arg_dest_dir" in
-    /*) # Absolute path
-        destdir="$arg_dest_dir/$arg_tag_name"
-        ;;
-    *)  # Make absolute path from relative path
-        destdir="$PWD/$arg_dest_dir/$arg_tag_name"
-        ;;
+/*) # Absolute path
+    destdir="$arg_dest_dir/$arg_tag_name"
+    ;;
+*) # Make absolute path from relative path
+    destdir="$PWD/$arg_dest_dir/$arg_tag_name"
+    ;;
 esac
 echo "-- Destination directory: $destdir"
 if [ -e "$destdir" ]; then
@@ -168,61 +164,61 @@
 #

 # Clone the remote repository
-workdir="`mktemp -d -p /var/tmp openvpn-build-release-XXXXXX`"
+workdir="$(mktemp -d -p /var/tmp openvpn-build-release-XXXXXX)"
 cd $workdir
 echo "-- Working directory: $workdir"
 echo "-- git clone $giturl"
-git clone $giturl openvpn-gen-tarball 2> "$workdir/git-clone.log" 1>&2
+git clone $giturl openvpn-gen-tarball 2>"$workdir/git-clone.log" 1>&2
 if [ $? -ne 0 ]; then
     echo "** ERROR **  git clone failed.  See $workdir/git-clone.log for details"
-    exit 3;
+    exit 3
 fi
 cd openvpn-gen-tarball

 # Check out the proper release tag
 echo "-- Checking out tag $arg_tag_name ... "
-git checkout -b mkrelease "$arg_tag_name" 2> "$workdir/git-checkout-tag.log" 1>&2
+git checkout -b mkrelease "$arg_tag_name" 2>"$workdir/git-checkout-tag.log" 1>&2
 if [ $? -ne 0 ]; then
     echo "** ERROR **  git checkout failed.  See $workdir/git-checkout-tag.log for details"
-    exit 3;
+    exit 3
 fi

 # Prepare the source tree
 echo "-- Running autoreconf + a simple configure ... "
-(autoreconf -vi && ./configure) 2> "$workdir/autotools-prep.log" 1>&2
+(autoreconf -vi && ./configure) 2>"$workdir/autotools-prep.log" 1>&2
 if [ $? -ne 0 ]; then
     echo "** ERROR **  Failed running autotools.  See $workdir/autotools-prep.log for details"
-    exit 3;
+    exit 3
 fi

 # Generate the tar/zip files
 echo "-- Running make distcheck (generates .tar.gz) ... "
-(make distcheck) 2> "$workdir/make-distcheck.log" 1>&2
+(make distcheck) 2>"$workdir/make-distcheck.log" 1>&2
 if [ $? -ne 0 ]; then
     echo "** ERROR **  make distcheck failed.  See $workdir/make-distcheck.log for details"
-    exit 3;
+    exit 3
 fi
 copy_files tar.gz "$destdir"

 echo "-- Running make dist-xz (generates .tar.xz) ... "
-(make dist-xz) 2> "$workdir/make-dist-xz.log" 1>&2
+(make dist-xz) 2>"$workdir/make-dist-xz.log" 1>&2
 if [ $? -ne 0 ]; then
     echo "** ERROR **  make dist-xz failed.  See $workdir/make-dist-xz.log for details"
-    exit 3;
+    exit 3
 fi
 copy_files tar.xz "$destdir"

 echo "-- Running make dist-zip (generates .zip) ... "
-(make dist-zip) 2> "$workdir/make-dist-zip.log" 1>&2
+(make dist-zip) 2>"$workdir/make-dist-zip.log" 1>&2
 if [ $? -ne 0 ]; then
     echo "** ERROR **  make dist-zip failed.  See $workdir/make-dist-zip.log for details"
-    exit 3;
+    exit 3
 fi
 copy_files zip "$destdir"

 # Generate SHA256 checksums
 cd "$destdir"
-sha256sum openvpn-*.tar.{gz,xz} openvpn-*.zip > "openvpn-$arg_tag_name.sha256sum"
+sha256sum openvpn-*.tar.{gz,xz} openvpn-*.zip >"openvpn-$arg_tag_name.sha256sum"

 # Sign all the files
 echo "-- Signing files ... "
diff --git a/dev-tools/git-pre-commit-format.sh b/dev-tools/git-pre-commit-format.sh
index 9b2ecaf..f475130 100755
--- a/dev-tools/git-pre-commit-format.sh
+++ b/dev-tools/git-pre-commit-format.sh
@@ -26,7 +26,6 @@
 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-
 # git pre-commit hook that runs a stylecheck.
 # Features:
 #  - abort commit when commit does not comply with the style guidelines
@@ -43,12 +42,11 @@
 # exit on error
 set -e

-
 # If called so, install this script as pre-commit hook
-if [ "$1" = "install" ] ; then
+if [ "$1" = "install" ]; then
     TARGET="$(git rev-parse --git-path hooks)/pre-commit"

-    if [ -e "$TARGET" ] ; then
+    if [ -e "$TARGET" ]; then
         printf "$TARGET file exists. Won't overwrite.\n"
         printf "Aborting installation.\n"
         exit 1
@@ -67,13 +65,13 @@
     local extension=".${filename##*.}"
     local ext

-    for ext in .c .h ; do [ "$ext" = "$extension" ] && return 0; done
+    for ext in .c .h; do [ "$ext" = "$extension" ] && return 0; done

     return 1
 }

 # necessary check for initial commit
-if git rev-parse --verify HEAD >/dev/null 2>&1 ; then
+if git rev-parse --verify HEAD >/dev/null 2>&1; then
     against=HEAD
 else
     # Initial commit: diff against an empty tree object
@@ -88,8 +86,8 @@

     # Allow to use in parallel with pre-commit
     if [ $(basename "$0") = "pre-commit.legacy" ]; then
-       echo "Skipping clang-format check in favor of pre-commit"
-       exit 0
+        echo "Skipping clang-format check in favor of pre-commit"
+        exit 0
     fi
 else
     TOOL=uncrustify
@@ -98,7 +96,7 @@
     TOOL_CMD="$TOOL_BIN -q -l C -c $UNCRUST_CONFIG"

     # make sure the config file is correctly set
-    if [ ! -f "$UNCRUST_CONFIG" ] ; then
+    if [ ! -f "$UNCRUST_CONFIG" ]; then
         printf "Error: uncrustify config file not found.\n"
         printf "Expected to find it at $UNCRUST_CONFIG.\n"
         printf "Aborting commit.\n"
@@ -106,7 +104,7 @@
     fi
 fi

-if [ -z "$TOOL_BIN" ] ; then
+if [ -z "$TOOL_BIN" ]; then
     printf "Error: $TOOL executable not found.\n"
     printf "Is it installed and in your \$PATH?\n"
     printf "Aborting commit.\n"
@@ -120,44 +118,43 @@
 # create one patch containing all changes to the files
 # sed to remove quotes around the filename, if inserted by the system
 # (done sometimes, if the filename contains special characters, like the quote itself)
-git diff-index --cached --diff-filter=ACMR --name-only $against -- | \
-sed -e 's/^"\(.*\)"$/\1/' | \
-while read file
-do
-    # ignore file if we do check for file extensions and the file
-    # does not match the extensions .c or .h
-    if ! matches_extension "$file"; then
-        continue;
-    fi
+git diff-index --cached --diff-filter=ACMR --name-only $against -- |
+    sed -e 's/^"\(.*\)"$/\1/' |
+    while read file; do
+        # ignore file if we do check for file extensions and the file
+        # does not match the extensions .c or .h
+        if ! matches_extension "$file"; then
+            continue
+        fi

-    # escape special characters in the target filename:
-    # phase 1 (characters escaped in the output diff):
-    #     - '\': backslash needs to be escaped in the output diff
-    #     - '"': quote needs to be escaped in the output diff if present inside
-    #            of the filename, as it used to bracket the entire filename part
-    # phase 2 (characters escaped in the match replacement):
-    #     - '\': backslash needs to be escaped again for sed itself
-    #            (i.e. double escaping after phase 1)
-    #     - '&': would expand to matched string
-    #     - '|': used as sed split char instead of '/'
-    # printf %s particularly important if the filename contains the % character
-    file_escaped_target=$(printf "%s" "$file" | sed -e 's/[\"]/\\&/g' -e 's/[\&|]/\\&/g')
+        # escape special characters in the target filename:
+        # phase 1 (characters escaped in the output diff):
+        #     - '\': backslash needs to be escaped in the output diff
+        #     - '"': quote needs to be escaped in the output diff if present inside
+        #            of the filename, as it used to bracket the entire filename part
+        # phase 2 (characters escaped in the match replacement):
+        #     - '\': backslash needs to be escaped again for sed itself
+        #            (i.e. double escaping after phase 1)
+        #     - '&': would expand to matched string
+        #     - '|': used as sed split char instead of '/'
+        # printf %s particularly important if the filename contains the % character
+        file_escaped_target=$(printf "%s" "$file" | sed -e 's/[\"]/\\&/g' -e 's/[\&|]/\\&/g')

-    # uncrustify our sourcefile, create a patch with diff and append it to our $patch
-    # The sed call is necessary to transform the patch from
-    #    --- - timestamp
-    #    +++ $tmpout timestamp
-    # to both lines working on the same file and having a a/ and b/ prefix.
-    # Else it can not be applied with 'git apply'.
-    git show ":$file" | $TOOL_CMD > "$tmpout"
-    git show ":$file" | diff -u -- - "$tmpout" | \
-        sed -e "1s|--- -|--- \"b/$file_escaped_target\"|" -e "2s|+++ $tmpout|+++ \"a/$file_escaped_target\"|" >> "$patch"
-done
+        # uncrustify our sourcefile, create a patch with diff and append it to our $patch
+        # The sed call is necessary to transform the patch from
+        #    --- - timestamp
+        #    +++ $tmpout timestamp
+        # to both lines working on the same file and having a a/ and b/ prefix.
+        # Else it can not be applied with 'git apply'.
+        git show ":$file" | $TOOL_CMD >"$tmpout"
+        git show ":$file" | diff -u -- - "$tmpout" |
+            sed -e "1s|--- -|--- \"b/$file_escaped_target\"|" -e "2s|+++ $tmpout|+++ \"a/$file_escaped_target\"|" >>"$patch"
+    done

 rm -f "$tmpout"

 # if no patch has been generated all is ok, clean up the file stub and exit
-if [ ! -s "$patch" ] ; then
+if [ ! -s "$patch" ]; then
     rm -f "$patch"
     exit 0
 fi
@@ -165,7 +162,7 @@
 # a patch has been created, notify the user and exit
 printf "Formatting of some code does not follow the project guidelines.\n"

-if [ $(wc -l < $patch) -gt 80 ] ; then
+if [ $(wc -l <$patch) -gt 80 ]; then
     printf "The file $patch contains the necessary fixes.\n"
 else
     printf "Here's the patch that fixes the formatting:\n\n"
diff --git a/dev-tools/run-cppcheck.sh b/dev-tools/run-cppcheck.sh
index 40db33e..a7aa3c4 100755
--- a/dev-tools/run-cppcheck.sh
+++ b/dev-tools/run-cppcheck.sh
@@ -20,24 +20,23 @@
  --check-level=exhaustive --max-configs=10 \
  --error-exitcode=1"

-
 set -x

 mkdir -p "$CPPCHECK_DIR"
 cd "${SOURCE_DIR}"
 cppcheck $COMMON_ARGS $INCLUDE_FLAGS \
-         --platform=unix64 \
-         --library=posix.cfg --library=bsd.cfg --library=gnu.cfg \
-         -U_WIN32 \
-         src/openvpn/ src/compat/ src/plugins/ sample/ \
-         tests/unit_tests/example_test/ tests/unit_tests/openvpn/ \
-         tests/unit_tests/plugins/
+    --platform=unix64 \
+    --library=posix.cfg --library=bsd.cfg --library=gnu.cfg \
+    -U_WIN32 \
+    src/openvpn/ src/compat/ src/plugins/ sample/ \
+    tests/unit_tests/example_test/ tests/unit_tests/openvpn/ \
+    tests/unit_tests/plugins/
 cppcheck $COMMON_ARGS \
-         --platform=win64 \
-         --library=windows.cfg \
-         -D_WIN32 \
-         -UTARGET_LINUX -UTARGET_FREEBSD -UTARGET_OPENBSD -UTARGET_NETBSD \
-         -UTARGET_DARWIN -UTARGET_ANDROID -UTARGET_SOLARIS -UTARGET_DRAGONFLY \
-         -UTARGET_AIX \
-         src/openvpn* src/compat/ \
-         tests/unit_tests/example_test/ tests/unit_tests/openvpn*
+    --platform=win64 \
+    --library=windows.cfg \
+    -D_WIN32 \
+    -UTARGET_LINUX -UTARGET_FREEBSD -UTARGET_OPENBSD -UTARGET_NETBSD \
+    -UTARGET_DARWIN -UTARGET_ANDROID -UTARGET_SOLARIS -UTARGET_DRAGONFLY \
+    -UTARGET_AIX \
+    src/openvpn* src/compat/ \
+    tests/unit_tests/example_test/ tests/unit_tests/openvpn*
diff --git a/dev-tools/update-copyright.sh b/dev-tools/update-copyright.sh
index 96546dd..7ca6002 100755
--- a/dev-tools/update-copyright.sh
+++ b/dev-tools/update-copyright.sh
@@ -34,8 +34,7 @@
 COPY_YEAR="$1"

 cd "$(git rev-parse --show-toplevel)"
-for file in $(git ls-files | grep -v vendor/);
-do
+for file in $(git ls-files | grep -v vendor/); do
     echo -n "Updating $file ..."
     # The first sed operation covers 20xx-20yy copyright lines,
     # The second sed operation changes 20xx -> 20xx-20yy
diff --git a/tests/lwip_client_up.sh b/tests/lwip_client_up.sh
index a6b4d24..b1941a4 100755
--- a/tests/lwip_client_up.sh
+++ b/tests/lwip_client_up.sh
@@ -2,16 +2,17 @@
 #
 # Determine the OpenVPN PID from its pid file. This works reliably even when
 # the OpenVPN process is backgrounded for parallel tests.
-MY_PPID=`cat $pid`
+MY_PPID=$(cat $pid)

 # Add this client's VPN IP and PID to a file. This enables
 # t_server_null_client.sh to kill this OpenVPN client after fping tests have
 # finished.
-echo "$ifconfig_local,$MY_PPID" >> ./$test_name.lwip
+echo "$ifconfig_local,$MY_PPID" >>./$test_name.lwip

 # Wait long enough to allow fping tests to finish. Also ensure that this
 # OpenVPN client is killed even if t_server_null_client.sh failed to do it.
-(sleep 15
-echo "ERROR: t_server_null_client.sh failed to kill OpenVPN client with PID $MY_PPID in test $test_name. Killing it in lwip_client_up.sh."
-kill -15 $MY_PPID
+(
+    sleep 15
+    echo "ERROR: t_server_null_client.sh failed to kill OpenVPN client with PID $MY_PPID in test $test_name. Killing it in lwip_client_up.sh."
+    kill -15 $MY_PPID
 ) &
diff --git a/tests/null_client_up.sh b/tests/null_client_up.sh
index d4df0c6..be339ee 100755
--- a/tests/null_client_up.sh
+++ b/tests/null_client_up.sh
@@ -4,8 +4,11 @@

 # Determine the OpenVPN PID from its pid file. This works reliably even when
 # the OpenVPN process is backgrounded for parallel tests.
-MY_PPID=`cat $pid`
+MY_PPID=$(cat $pid)

 # Allow OpenVPN to finish initializing while waiting in the background and then
 # killing the process gracefully.
-(sleep 5 ; kill -15 $MY_PPID) &
+(
+    sleep 5
+    kill -15 $MY_PPID
+) &
diff --git a/tests/t_client.sh.in b/tests/t_client.sh.in
index 7233187..4b6c51d 100755
--- a/tests/t_client.sh.in
+++ b/tests/t_client.sh.in
@@ -19,9 +19,9 @@
 srcdir="${srcdir:-.}"
 top_builddir="${top_builddir:-..}"
 openvpn="${openvpn:-${top_builddir}/src/openvpn/openvpn}"
-if [ -r "${top_builddir}"/t_client.rc ] ; then
+if [ -r "${top_builddir}"/t_client.rc ]; then
     . "${top_builddir}"/t_client.rc
-elif [ -r "${srcdir}"/t_client.rc ] ; then
+elif [ -r "${srcdir}"/t_client.rc ]; then
     . "${srcdir}"/t_client.rc
 else
     echo "$0: cannot find 't_client.rc' in build dir ('${top_builddir}')" >&2
@@ -32,37 +32,35 @@
 # Check for external dependencies
 FPING="fping"
 FPING6="fping6"
-which fping > /dev/null
+which fping >/dev/null
 if [ $? -ne 0 ]; then
     echo "$0: fping is not available in \$PATH" >&2
     exit "${TCLIENT_SKIP_RC}"
 fi
-which fping6 > /dev/null
+which fping6 >/dev/null
 if [ $? -ne 0 ]; then
     echo "$0: fping6 is not available in \$PATH, assuming fping 4.0 or later" >&2
     FPING="fping -4"
     FPING6="fping -6"
 fi

-KILL_EXEC=`which kill`
+KILL_EXEC=$(which kill)
 if [ $? -ne 0 ]; then
     echo "$0: kill not found in \$PATH" >&2
     exit "${TCLIENT_SKIP_RC}"
 fi

-if [ ! -x "${openvpn}" ]
-then
+if [ ! -x "${openvpn}" ]; then
     echo "no (executable) openvpn binary in current build tree. FAIL." >&2
     exit 1
 fi

-if [ ! -w . ]
-then
+if [ ! -w . ]; then
     echo "current directory is not writable (required for logging). FAIL." >&2
     exit 1
 fi

-if [ -z "$TEST_RUN_LIST" ] ; then
+if [ -z "$TEST_RUN_LIST" ]; then
     echo "TEST_RUN_LIST empty, no tests defined.  SKIP test." >&2
     exit "${TCLIENT_SKIP_RC}"
 fi
@@ -72,16 +70,14 @@

 # make sure we have permissions to run ifconfig/route from OpenVPN
 # can't use "id -u" here - doesn't work on Solaris
-ID=`id`
-if expr "$ID" : "uid=0" >/dev/null
-then :
+ID=$(id)
+if expr "$ID" : "uid=0" >/dev/null; then
+    :
 else
-    if [ "${PREFER_KSU}" -eq 1 ];
-    then
+    if [ "${PREFER_KSU}" -eq 1 ]; then
         # Check if we have a valid kerberos ticket
         klist -l 1>/dev/null 2>/dev/null
-        if [ $? -ne 0 ];
-        then
+        if [ $? -ne 0 ]; then
             # No kerberos ticket found, skip ksu and fallback to RUN_SUDO
             PREFER_KSU=0
             echo "$0: No Kerberos ticket available.  Will not use ksu."
@@ -90,8 +86,7 @@
         fi
     fi

-    if [ -z "$RUN_SUDO" ]
-    then
+    if [ -z "$RUN_SUDO" ]; then
         echo "$0: this test must run be as root, or RUN_SUDO=... " >&2
         echo "      must be set correctly in 't_client.rc'. SKIP." >&2
         exit "${TCLIENT_SKIP_RC}"
@@ -99,19 +94,18 @@
         # We have to use sudo. Make sure that we (hopefully) do not have
         # to ask the users password during the test. This is done to
         # prevent timing issues, e.g. when the waits for openvpn to start
-	if $RUN_SUDO $KILL_EXEC -0 $$
-	then
-	    echo "$0: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
-	else
-	    echo "$0: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
-	    exit "${TCLIENT_SKIP_RC}"
-	fi
+        if $RUN_SUDO $KILL_EXEC -0 $$; then
+            echo "$0: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
+        else
+            echo "$0: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
+            exit "${TCLIENT_SKIP_RC}"
+        fi
     fi
 fi

-LOGDIR=t_client-`hostname`-`date +%Y%m%d-%H%M%S`
-if mkdir $LOGDIR
-then :
+LOGDIR=t_client-$(hostname)-$(date +%Y%m%d-%H%M%S)
+if mkdir $LOGDIR; then
+    :
 else
     echo "can't create log directory '$LOGDIR'. FAIL." >&2
     exit 1
@@ -128,103 +122,105 @@

 # output progress information
 #  depending on verbosity level, collect & print only on failure
-output_start()
-{
+output_start() {
     case $V in
-	0) outbuf="" ;;			# no per-test output at all
-	1) echo -e "$@"			# compact, details only on failure
-           outbuf="\n" ;;
-	*) echo -e "\n$@\n" ;;		# print all, with a bit formatting
+    0) outbuf="" ;; # no per-test output at all
+    1)
+        echo -e "$@" # compact, details only on failure
+        outbuf="\n"
+        ;;
+    *) echo -e "\n$@\n" ;; # print all, with a bit formatting
     esac
 }

-output()
-{
-    NO_NL=''; if [ "X$1" = "X-n" ] ; then NO_NL=$1 ; shift ; fi
+output() {
+    NO_NL=''
+    if [ "X$1" = "X-n" ]; then
+        NO_NL=$1
+        shift
+    fi
     case $V in
-	0) ;;				# no per-test output at all
-	1) outbuf="$outbuf$@" 		# print details only on failure
-	   test -z "$NO_NL" && outbuf="$outbuf\n"
-           ;;
-	*) echo -e $NO_NL "$@" ;;	# print everything
+    0) ;; # no per-test output at all
+    1)
+        outbuf="$outbuf$@" # print details only on failure
+        test -z "$NO_NL" && outbuf="$outbuf\n"
+        ;;
+    *) echo -e $NO_NL "$@" ;; # print everything
     esac
 }

 # print failure message, increase FAIL counter
-fail()
-{
+fail() {
     output "FAIL: $@\n"
-    fail_count=$(( $fail_count + 1 ))
+    fail_count=$(($fail_count + 1))
 }

 # print "all interface IP addresses" + "all routes"
 # this is higly system dependent...
-get_ifconfig_route()
-{
-    UNAME=`uname -s`
+get_ifconfig_route() {
+    UNAME=$(uname -s)
     case $UNAME in
-	Linux)
-            # linux / iproute2? (-> if configure got a path)
-            if [ -n "@IPROUTE@" ]
-            then
-                echo "-- linux iproute2 --"
-                @IPROUTE@ addr show     | grep -v valid_lft
-                @IPROUTE@ route show
-                @IPROUTE@ -o -6 route show | grep -v ' cache' | sed -E -e 's/ expires [0-9]*sec//' -e 's/ (mtu|hoplimit|cwnd|ssthresh) [0-9]+//g' -e 's/ (rtt|rttvar) [0-9]+ms//g'
-            else
-	        echo "-- linux / ifconfig --"
-	        LANG=C @IFCONFIG@ -a |egrep  "( addr:|encap:)"
-	        LANG=C @NETSTAT@ -rn -4 -6
-            fi
-            ;;
-	FreeBSD|NetBSD|Darwin)
-	   echo "-- FreeBSD/NetBSD/Darwin [MacOS X] --"
-	   @IFCONFIG@ -a | egrep "(flags=|inet)"
-	   @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
-	   ;;
-	OpenBSD)
-	   echo "-- OpenBSD --"
-	   @IFCONFIG@ -a | egrep "(flags=|inet)" | \
-		sed -e 's/pltime [0-9]*//' -e 's/vltime [0-9]*//'
-	   @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
-	   ;;
-	SunOS)
-	   echo "-- Solaris --"
-	   @IFCONFIG@ -a | egrep "(flags=|inet)"
-	   @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
-	   ;;
-	AIX)
-	   echo "-- AIX --"
-	   @IFCONFIG@ -a | egrep "(flags=|inet)"
-	   @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
-	   ;;
-        *)
-           echo "get_ifconfig_route(): no idea how to get info on your OS (`uname -s`).  FAIL." >&2
-           exit 20
-           ;;
+    Linux)
+        # linux / iproute2? (-> if configure got a path)
+        if [ -n "@IPROUTE@" ]; then
+            echo "-- linux iproute2 --"
+            @IPROUTE@ addr show | grep -v valid_lft
+            @IPROUTE@ route show
+            @IPROUTE@ -o -6 route show | grep -v ' cache' | sed -E -e 's/ expires [0-9]*sec//' -e 's/ (mtu|hoplimit|cwnd|ssthresh) [0-9]+//g' -e 's/ (rtt|rttvar) [0-9]+ms//g'
+        else
+            echo "-- linux / ifconfig --"
+            LANG=C @IFCONFIG@ -a | egrep "( addr:|encap:)"
+            LANG=C @NETSTAT@ -rn -4 -6
+        fi
+        ;;
+    FreeBSD | NetBSD | Darwin)
+        echo "-- FreeBSD/NetBSD/Darwin [MacOS X] --"
+        @IFCONFIG@ -a | egrep "(flags=|inet)"
+        @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
+        ;;
+    OpenBSD)
+        echo "-- OpenBSD --"
+        @IFCONFIG@ -a | egrep "(flags=|inet)" |
+            sed -e 's/pltime [0-9]*//' -e 's/vltime [0-9]*//'
+        @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
+        ;;
+    SunOS)
+        echo "-- Solaris --"
+        @IFCONFIG@ -a | egrep "(flags=|inet)"
+        @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
+        ;;
+    AIX)
+        echo "-- AIX --"
+        @IFCONFIG@ -a | egrep "(flags=|inet)"
+        @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
+        ;;
+    *)
+        echo "get_ifconfig_route(): no idea how to get info on your OS ($(uname -s)).  FAIL." >&2
+        exit 20
+        ;;
     esac

     # another round of per-platform information gathering, for DNS info
     # for most of the platforms "cat /etc/resolv.conf" is good enough
     # except Linux and MacOS
     case $UNAME in
-	Linux)
-            if [ -x /usr/bin/resolvectl -a -d /run/systemd/system ] ; then
-                echo "-- linux resolvectl --"
-                resolvectl status
-            else
-                echo "-- linux resolv.conf --"
-                cat /etc/resolv.conf
-            fi
-            ;;
-	Darwin)
-            echo "-- MacOS scutil --dns"
-            scutil --dns
-            ;;
-        *)
-            echo "-- resolv.conf --"
+    Linux)
+        if [ -x /usr/bin/resolvectl -a -d /run/systemd/system ]; then
+            echo "-- linux resolvectl --"
+            resolvectl status
+        else
+            echo "-- linux resolv.conf --"
             cat /etc/resolv.conf
-            ;;
+        fi
+        ;;
+    Darwin)
+        echo "-- MacOS scutil --dns"
+        scutil --dns
+        ;;
+    *)
+        echo "-- resolv.conf --"
+        cat /etc/resolv.conf
+        ;;
     esac
 }

@@ -232,21 +228,20 @@
 # check ifconfig
 #  arg1: "4" or "6" -> for message
 #  arg2: IPv4/IPv6 address that must show up in out of "get_ifconfig_route"
-check_ifconfig()
-{
-    proto=$1 ; shift
+check_ifconfig() {
+    proto=$1
+    shift
     expect_list="$@"

-    if [ -z "$expect_list" ] ; then return ; fi
-    if [ "$expect_list" = "-" ] ; then return ; fi
+    if [ -z "$expect_list" ]; then return; fi
+    if [ "$expect_list" = "-" ]; then return; fi

-    for expect in $expect_list
-    do
-	if get_ifconfig_route | fgrep "$expect" >/dev/null
-	then :
-	else
-	    fail "check_ifconfig(): expected IPv$proto address '$expect' not found in ifconfig output."
-	fi
+    for expect in $expect_list; do
+        if get_ifconfig_route | fgrep "$expect" >/dev/null; then
+            :
+        else
+            fail "check_ifconfig(): expected IPv$proto address '$expect' not found in ifconfig output."
+        fi
     done
 }

@@ -255,49 +250,49 @@
 #  arg1: "4" or "6" -> fping/fing6
 #  arg2: "want_ok" or "want_fail" (expected ping result)
 #  arg3... -> fping arguments (host list)
-run_ping_tests()
-{
-    proto=$1 ; want=$2 ; shift ; shift
+run_ping_tests() {
+    proto=$1
+    want=$2
+    shift
+    shift
     targetlist="$@"

     # "no targets" is fine
-    if [ -z "$targetlist" ] ; then return ; fi
+    if [ -z "$targetlist" ]; then return; fi

     case $proto in
-	4) cmd="$FPING" ;;
-	6) cmd="$FPING6" ;;
-	*) echo "internal error in run_ping_tests arg 1: '$proto'" >&2
-	   exit 1 ;;
+    4) cmd="$FPING" ;;
+    6) cmd="$FPING6" ;;
+    *)
+        echo "internal error in run_ping_tests arg 1: '$proto'" >&2
+        exit 1
+        ;;
     esac

     case $want in
-	want_ok)   sizes_list="64 1440 3000" ;;
-	want_fail) sizes_list="64" ;;
+    want_ok) sizes_list="64 1440 3000" ;;
+    want_fail) sizes_list="64" ;;
     esac

-    for bytes in $sizes_list
-    do
-	output "run IPv$proto ping tests ($want), $bytes byte packets..."
+    for bytes in $sizes_list; do
+        output "run IPv$proto ping tests ($want), $bytes byte packets..."

-	echo "$cmd -b $bytes -C 20 -p 250 -q $fping_args $targetlist" >>$LOGDIR/$SUF:fping.out
-	$cmd -b $bytes -C 20 -p 250 -q $fping_args $targetlist >>$LOGDIR/$SUF:fping.out 2>&1
+        echo "$cmd -b $bytes -C 20 -p 250 -q $fping_args $targetlist" >>$LOGDIR/$SUF:fping.out
+        $cmd -b $bytes -C 20 -p 250 -q $fping_args $targetlist >>$LOGDIR/$SUF:fping.out 2>&1

-	# while OpenVPN is running, pings must succeed (want='want_ok')
-	# before OpenVPN is up, pings must NOT succeed (want='want_fail')
+        # while OpenVPN is running, pings must succeed (want='want_ok')
+        # before OpenVPN is up, pings must NOT succeed (want='want_fail')

-	rc=$?
-	if [ $rc = 0 ] 				# all ping OK
-	then
-	    if [ $want = "want_fail" ]		# not what we want
-	    then
-		fail "IPv$proto ping test succeeded, but needs to *fail*."
-	    fi
-	else					# ping failed
-	    if [ $want = "want_ok" ]		# not what we wanted
-	    then
-		fail "IPv$proto ping test ($bytes bytes) failed, but should succeed."
-	    fi
-	fi
+        rc=$?
+        if [ $rc = 0 ]; then                 # all ping OK
+            if [ $want = "want_fail" ]; then # not what we want
+                fail "IPv$proto ping test succeeded, but needs to *fail*."
+            fi
+        else                               # ping failed
+            if [ $want = "want_ok" ]; then # not what we wanted
+                fail "IPv$proto ping test ($bytes bytes) failed, but should succeed."
+            fi
+        fi
     done
 }

@@ -308,8 +303,7 @@
 SUMMARY_SKIP=
 SUMMARY_FAIL=

-for SUF in $TEST_RUN_LIST
-do
+for SUF in $TEST_RUN_LIST; do
     # get config variables
     eval test_prep=\"\$PREPARE_$SUF\"
     eval test_check_skip=\"\$CHECK_SKIP_$SUF\"
@@ -336,11 +330,13 @@

     if [ -n "$test_check_skip" ]; then
         output "check whether we need to skip: '$test_check_skip'"
-        if eval $test_check_skip; then :
+        if eval $test_check_skip; then
+            :
         else
             output "skip check failed, SKIP test $SUF."
-	    SUMMARY_SKIP="$SUMMARY_SKIP $SUF"
-	    echo -e "$outbuf" ; continue
+            SUMMARY_SKIP="$SUMMARY_SKIP $SUF"
+            echo -e "$outbuf"
+            continue
         fi
     fi

@@ -355,13 +351,14 @@
     output "\nrun pre-openvpn ping tests - targets must not be reachable..."
     run_ping_tests 4 want_fail "$ping4_hosts"
     run_ping_tests 6 want_fail "$ping6_hosts"
-    if [ "$fail_count" = 0 ] ; then
+    if [ "$fail_count" = 0 ]; then
         output "OK.\n"
     else
-	fail "make sure that ping hosts are ONLY reachable via VPN, SKIP test $SUF."
-	SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
-	exit_code=31
-	echo -e "$outbuf" ; continue
+        fail "make sure that ping hosts are ONLY reachable via VPN, SKIP test $SUF."
+        SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
+        exit_code=31
+        echo -e "$outbuf"
+        continue
     fi

     pidfile="${top_builddir}/tests/$LOGDIR/openvpn-$SUF.pid"
@@ -376,18 +373,17 @@
     # to $ovpn_init_check times.
     ovpn_init_check=30
     ovpn_init_success=0
-    while [ $ovpn_init_check -gt 0 ];
-    do
-       sleep 1  # Wait for OpenVPN to initialize and have had time to write the pid file
-       grep "Initialization Sequence Completed" $LOGDIR/$SUF:openvpn.log >/dev/null
-       if [ $? -eq 0 ]; then
-           ovpn_init_check=0
-           ovpn_init_success=1
-       fi
-       ovpn_init_check=$(( $ovpn_init_check - 1 ))
+    while [ $ovpn_init_check -gt 0 ]; do
+        sleep 1 # Wait for OpenVPN to initialize and have had time to write the pid file
+        grep "Initialization Sequence Completed" $LOGDIR/$SUF:openvpn.log >/dev/null
+        if [ $? -eq 0 ]; then
+            ovpn_init_check=0
+            ovpn_init_success=1
+        fi
+        ovpn_init_check=$(($ovpn_init_check - 1))
     done

-    opid=`cat $pidfile`
+    opid=$(cat $pidfile)
     if [ -n "$opid" ]; then
         output "  OpenVPN running with PID $opid"
     else
@@ -398,16 +394,17 @@
     if [ $ovpn_init_success -ne 1 -o -z "$opid" ]; then
         output "$0:  OpenVPN did not initialize in a reasonable time"
         if [ -n "$opid" ]; then
-           $RUN_SUDO $KILL_EXEC $opid
+            $RUN_SUDO $KILL_EXEC $opid
         fi
         $RUN_SUDO $KILL_EXEC $sudopid
-	output "tail -5 $SUF:openvpn.log"
-	output "`tail -5 $LOGDIR/$SUF:openvpn.log`"
-	fail "skip rest of sub-tests for test run $SUF."
-	trap - 0 1 2 3 15
-	SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
-	exit_code=30
-	echo -e "$outbuf" ; continue
+        output "tail -5 $SUF:openvpn.log"
+        output "$(tail -5 $LOGDIR/$SUF:openvpn.log)"
+        fail "skip rest of sub-tests for test run $SUF."
+        trap - 0 1 2 3 15
+        SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
+        exit_code=30
+        echo -e "$outbuf"
+        continue
     fi

     # make sure openvpn client is terminated in case shell exits
@@ -418,17 +415,16 @@
     output "save ifconfig+route"
     get_ifconfig_route >$LOGDIR/$SUF:ifconfig_route.txt

-    if [ "$expect_ifconfig4" = "-" ] ; then
+    if [ "$expect_ifconfig4" = "-" ]; then
         output "skip ifconfig+route check"
     else
-	output -n "compare pre-openvpn ifconfig+route with current values..."
-	if diff $LOGDIR/$SUF:ifconfig_route_pre.txt \
-		$LOGDIR/$SUF:ifconfig_route.txt >/dev/null
-	then
-	    fail "no differences between ifconfig/route before OpenVPN start and now."
-	else
-	    output " OK!\n"
-	fi
+        output -n "compare pre-openvpn ifconfig+route with current values..."
+        if diff $LOGDIR/$SUF:ifconfig_route_pre.txt \
+            $LOGDIR/$SUF:ifconfig_route.txt >/dev/null; then
+            fail "no differences between ifconfig/route before OpenVPN start and now."
+        else
+            output " OK!\n"
+        fi
     fi

     # post init script needed?
@@ -449,8 +445,8 @@
     $RUN_SUDO $KILL_EXEC $opid
     wait $!
     rc=$?
-    if [ $rc != 0 ] ; then
-	fail "OpenVPN return code $rc, expect 0"
+    if [ $rc != 0 ]; then
+        fail "OpenVPN return code $rc, expect 0"
     fi

     output "\nsave post-openvpn ifconfig + route..."
@@ -458,23 +454,22 @@

     output -n "compare pre- and post-openvpn ifconfig + route..."
     if diff $LOGDIR/$SUF:ifconfig_route_pre.txt \
-	    $LOGDIR/$SUF:ifconfig_route_post.txt >$LOGDIR/$SUF:ifconfig_route_diff.txt
-    then
-	output " OK.\n"
+        $LOGDIR/$SUF:ifconfig_route_post.txt >$LOGDIR/$SUF:ifconfig_route_diff.txt; then
+        output " OK.\n"
     else
-	output "\n\n" "`cat $LOGDIR/$SUF:ifconfig_route_diff.txt`" "\n"
-	fail "differences between pre- and post-ifconfig/route."
+        output "\n\n" "$(cat $LOGDIR/$SUF:ifconfig_route_diff.txt)" "\n"
+        fail "differences between pre- and post-ifconfig/route."
     fi
-    if [ "$fail_count" = 0 ] ; then
+    if [ "$fail_count" = 0 ]; then
         output "test run $SUF: all tests OK.\n"
-	SUMMARY_OK="$SUMMARY_OK $SUF"
+        SUMMARY_OK="$SUMMARY_OK $SUF"
     else
-	if [ "$V" -gt 0 ] ; then
-	    echo -e -n "$outbuf"
-	    echo -e "test run $SUF: $fail_count test failures. FAIL.\n"
+        if [ "$V" -gt 0 ]; then
+            echo -e -n "$outbuf"
+            echo -e "test run $SUF: $fail_count test failures. FAIL.\n"
         fi
-	SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
-	exit_code=30
+        SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
+        exit_code=30
     fi

     if [ -n "$test_cleanup" ]; then
@@ -484,9 +479,9 @@

 done

-if [ -z "$SUMMARY_OK" ] ; then SUMMARY_OK=" none"; fi
-if [ -z "$SUMMARY_SKIP" ] ; then SUMMARY_SKIP=" none"; fi
-if [ -z "$SUMMARY_FAIL" ] ; then SUMMARY_FAIL=" none"; fi
+if [ -z "$SUMMARY_OK" ]; then SUMMARY_OK=" none"; fi
+if [ -z "$SUMMARY_SKIP" ]; then SUMMARY_SKIP=" none"; fi
+if [ -z "$SUMMARY_FAIL" ]; then SUMMARY_FAIL=" none"; fi
 echo "Test sets succeeded:$SUMMARY_OK."
 echo "Test sets skipped:$SUMMARY_SKIP."
 echo "Test sets failed:$SUMMARY_FAIL."
diff --git a/tests/t_cltsrv.sh b/tests/t_cltsrv.sh
index 6b7df65..f4442a2 100755
--- a/tests/t_cltsrv.sh
+++ b/tests/t_cltsrv.sh
@@ -24,19 +24,19 @@
 trap "rm -f log.$$ log.$$.signal ; trap 0 ; exit 77" 1 2 15
 trap "rm -f log.$$ log.$$.signal ; exit 1" 0 3
 addopts=
-case `uname -s` in
-    FreeBSD)
+case $(uname -s) in
+FreeBSD)
     # FreeBSD jails map the outgoing IP to the jail IP - we need to
     # allow the real IP unless we want the test to run forever.
-    if test "`sysctl 2>/dev/null -n security.jail.jailed`" = 1 \
-    || ps -ostate= -p $$ | grep -q J; then
-	addopts="--float"
-	if test "x`ifconfig | grep inet`" = x ; then
-	    echo "###"
-	    echo "### To run the test in a FreeBSD jail, you MUST add an IP alias for the jail's IP."
-	    echo "###"
-	    exit 77
-	fi
+    if test "$(sysctl 2>/dev/null -n security.jail.jailed)" = 1 ||
+        ps -ostate= -p $$ | grep -q J; then
+        addopts="--float"
+        if test "x$(ifconfig | grep inet)" = x; then
+            echo "###"
+            echo "### To run the test in a FreeBSD jail, you MUST add an IP alias for the jail's IP."
+            echo "###"
+            exit 77
+        fi
     fi
     ;;
 esac
@@ -45,29 +45,37 @@
 # skip) test if it isn't.
 downscript="../tests/t_cltsrv-down.sh"
 root="${top_srcdir}/sample"
-test -x "${root}/${downscript}" || chmod +x "${root}/${downscript}" || { echo >&2 "${root}/${downscript} is not executable, failing." ; exit 1 ; }
+test -x "${root}/${downscript}" || chmod +x "${root}/${downscript}" || {
+    echo >&2 "${root}/${downscript} is not executable, failing."
+    exit 1
+}
 echo "The following test will take about two minutes." >&2
 echo "If the addresses are in use, this test will retry up to two times." >&2

 # go
 success=0
-for i in 1 2 3 ; do
-  set +e
-  (
-  "${openvpn}" --script-security 2 --cd "${root}" ${addopts} --setenv role srv --down "${downscript}" --tls-exit --ping-exit 180 --config "sample-config-files/loopback-server" &
-  "${openvpn}" --script-security 2 --cd "${top_srcdir}/sample" ${addopts} --setenv role clt --down "${downscript}" --tls-exit --ping-exit 180 --config "sample-config-files/loopback-client"
-  ) 3>log.$$.signal >log.$$ 2>&1
-  e1=$?
-  wait $!
-  e2=$?
-  grep 'TCP/UDP: Socket bind failed on local address.*in use' log.$$ >/dev/null && {
-    echo 'address in use, retrying in 150 s'
-    sleep 150
-    continue
-  }
-  grep -v ':inactive$' log.$$.signal >/dev/null && { cat log.$$.signal ; echo ; cat log.$$ ; exit 1 ; }
-  success=1
-  break
+for i in 1 2 3; do
+    set +e
+    (
+        "${openvpn}" --script-security 2 --cd "${root}" ${addopts} --setenv role srv --down "${downscript}" --tls-exit --ping-exit 180 --config "sample-config-files/loopback-server" &
+        "${openvpn}" --script-security 2 --cd "${top_srcdir}/sample" ${addopts} --setenv role clt --down "${downscript}" --tls-exit --ping-exit 180 --config "sample-config-files/loopback-client"
+    ) 3>log.$$.signal >log.$$ 2>&1
+    e1=$?
+    wait $!
+    e2=$?
+    grep 'TCP/UDP: Socket bind failed on local address.*in use' log.$$ >/dev/null && {
+        echo 'address in use, retrying in 150 s'
+        sleep 150
+        continue
+    }
+    grep -v ':inactive$' log.$$.signal >/dev/null && {
+        cat log.$$.signal
+        echo
+        cat log.$$
+        exit 1
+    }
+    success=1
+    break
 done

 set -e
@@ -75,14 +83,14 @@
 # exit code - defaults to 0, PASS
 ec=0

-if [ $success != 1 ] ; then
-  # couldn't run test -- addresses in use, skip test
-  cat log.$$
-  ec=77
-elif [ $e1 != 0 ] || [ $e2 != 0 ] ; then
-  # failure -- fail test
-  cat log.$$
-  ec=1
+if [ $success != 1 ]; then
+    # couldn't run test -- addresses in use, skip test
+    cat log.$$
+    ec=77
+elif [ $e1 != 0 ] || [ $e2 != 0 ]; then
+    # failure -- fail test
+    cat log.$$
+    ec=1
 fi

 rm log.$$ log.$$.signal
diff --git a/tests/t_lpback.sh b/tests/t_lpback.sh
index 6802506..8379f8f 100755
--- a/tests/t_lpback.sh
+++ b/tests/t_lpback.sh
@@ -34,54 +34,57 @@

 # output progress information
 #  depending on verbosity level, collect & print only on failure
-test_start()
-{
+test_start() {
     case $V in
-        0) outbuf="" ;;                  # no per-test output at all
-        1) outbuf="$@" ;;                # compact, details only on failure
-        *) printf "$@" ;;                # print all
+    0) outbuf="" ;;   # no per-test output at all
+    1) outbuf="$@" ;; # compact, details only on failure
+    *) printf "$@" ;; # print all
     esac
 }
-test_end()
-{
-    RC=$1 ; LOG=$2
-    if [ $RC != 0 ]
-    then
+test_end() {
+    RC=$1
+    LOG=$2
+    if [ $RC != 0 ]; then
         case $V in
-            0) ;;                                # no per-test output
-            1) echo "$outbuf" "FAIL (RC=$RC)"; cat $LOG ;;
-            *) echo "FAIL (RC=$RC)"; cat $LOG ;;
+        0) ;; # no per-test output
+        1)
+            echo "$outbuf" "FAIL (RC=$RC)"
+            cat $LOG
+            ;;
+        *)
+            echo "FAIL (RC=$RC)"
+            cat $LOG
+            ;;
         esac
         e=1
-        tests_failed=$(( $tests_failed + 1 ))
+        tests_failed=$(($tests_failed + 1))
     else
         case $V in
-            0|1) ;;                              # no per-test output for 'OK'
-            *) echo "OK"                         # print all
+        0 | 1) ;;       # no per-test output for 'OK'
+        *) echo "OK" ;; # print all
         esac
-        tests_passed=$(( $tests_passed + 1 ))
+        tests_passed=$(($tests_passed + 1))
     fi
 }

 # if running with V=1, give an indication what test runs now
-if [ "$V" = 1  ] ; then
+if [ "$V" = 1 ]; then
     echo "$0: running with V=$V, only printing test fails"
 fi

-
 # Get list of supported ciphers from openvpn --show-ciphers output
-CIPHERS=$(${openvpn} --show-ciphers | \
-            sed -e '/The following/,/^$/d' -e s'/ .*//' -e '/^[[:space:]]*$/d')
+CIPHERS=$(${openvpn} --show-ciphers |
+    sed -e '/The following/,/^$/d' -e s'/ .*//' -e '/^[[:space:]]*$/d')

 # SK, 2014-06-04: currently the DES-EDE3-CFB1 implementation of OpenSSL is
 # broken (see http://rt.openssl.org/Ticket/Display.html?id=2867), so exclude
 # that cipher from this test.
 # GD, 2014-07-06 so is DES-CFB1
 # GD, 2014-07-06 do not test RC5-* either (fails on NetBSD w/o libcrypto_rc5)
-CIPHERS=$(echo "$CIPHERS" | egrep -v '^(DES-EDE3-CFB1|DES-CFB1|RC5-)' )
+CIPHERS=$(echo "$CIPHERS" | egrep -v '^(DES-EDE3-CFB1|DES-CFB1|RC5-)')

 e=0
-if [ -z "$CIPHERS" ] ; then
+if [ -z "$CIPHERS" ]; then
     echo "'openvpn --show-ciphers' FAILED (empty list)"
     e=1
 fi
@@ -91,10 +94,9 @@

 set +e

-for cipher in ${CIPHERS}
-do
+for cipher in ${CIPHERS}; do
     test_start "Testing cipher ${cipher}... "
-    ( "${openvpn}" --test-crypto --cipher ${cipher} ) >log.$$ 2>&1
+    ("${openvpn}" --test-crypto --cipher ${cipher}) >log.$$ 2>&1
     test_end $? log.$$
 done

@@ -121,7 +123,7 @@
     >log.$$ 2>&1
 test_end $? log.$$

-if [ "$V" -ge 1  ] ; then
+if [ "$V" -ge 1 ]; then
     echo "$0: tests passed: $tests_passed  failed: $tests_failed"
 fi

diff --git a/tests/t_net.sh b/tests/t_net.sh
index 8134832..fbedb54 100755
--- a/tests/t_net.sh
+++ b/tests/t_net.sh
@@ -9,7 +9,6 @@
 top_builddir="${top_builddir:-..}"
 openvpn="${openvpn:-${top_builddir}/src/openvpn/openvpn}"

-
 # bail out right away on non-linux. NetLink (the object of this test) is only
 # used on Linux, therefore testing other platform is not needed.
 #
@@ -31,8 +30,7 @@

 LAST_STATE=$((${#GET_STATE[@]} - 1))

-reload_dummy()
-{
+reload_dummy() {
     $RUN_SUDO ip link del $IFACE
     $RUN_SUDO ip link add $IFACE address 00:11:22:33:44:55 type dummy
     $RUN_SUDO ip link set dev $IFACE state up
@@ -43,8 +41,7 @@
     fi
 }

-run_test()
-{
+run_test() {
     # run all test cases from 0 to $1 in sequence
     CMD=
     for k in $(seq 0 $1); do
@@ -69,7 +66,6 @@
     done
 }

-
 ## execution starts here

 # t_client.rc required only for RUN_SUDO definition
@@ -89,21 +85,18 @@
     exit 77
 fi

-
 # Ensure PREFER_KSU is in a known state
 PREFER_KSU="${PREFER_KSU:-0}"

 # make sure we have permissions to run the networking unit-test
-ID=`id`
-if expr "$ID" : "uid=0" >/dev/null
-then :
+ID=$(id)
+if expr "$ID" : "uid=0" >/dev/null; then
+    :
 else
-    if [ "${PREFER_KSU}" -eq 1 ];
-    then
+    if [ "${PREFER_KSU}" -eq 1 ]; then
         # Check if we have a valid kerberos ticket
         klist -l 1>/dev/null 2>/dev/null
-        if [ $? -ne 0 ];
-        then
+        if [ $? -ne 0 ]; then
             # No kerberos ticket found, skip ksu and fallback to RUN_SUDO
             PREFER_KSU=0
             echo "$0: No Kerberos ticket available.  Will not use ksu."
@@ -112,16 +105,14 @@
         fi
     fi

-    if [ -z "$RUN_SUDO" ]
-    then
+    if [ -z "$RUN_SUDO" ]; then
         echo "$0: no RUN_SUDO=... in t_client.rc or environment, defaulting to 'sudo'." >&2
         echo "      if that does not work, set RUN_SUDO= correctly for your system." >&2
         RUN_SUDO="sudo"
     fi

     # check that we can run the unit-test binary with sudo
-    if $RUN_SUDO $UNIT_TEST test
-    then
+    if $RUN_SUDO $UNIT_TEST test; then
         echo "$0: $RUN_SUDO $UNIT_TEST succeeded, good."
     else
         echo "$0: $RUN_SUDO $UNIT_TEST failed, cannot go on. SKIP." >&2
diff --git a/tests/t_server_null.sh b/tests/t_server_null.sh
index 74ffd52..c633614 100755
--- a/tests/t_server_null.sh
+++ b/tests/t_server_null.sh
@@ -2,7 +2,7 @@
 #
 TSERVER_NULL_SKIP_RC="${TSERVER_NULL_SKIP_RC:-77}"

-if ! [ -r "./t_server_null.rc" ] ; then
+if ! [ -r "./t_server_null.rc" ]; then
     echo "${0}: cannot find './t_server_null.rc. SKIPPING TEST.'" >&2
     exit "${TSERVER_NULL_SKIP_RC}"
 fi
@@ -22,11 +22,10 @@
 # make sure we have permissions to run ifconfig/route from OpenVPN
 # can't use "id -u" here - doesn't work on Solaris
 ID=$(id)
-if expr "$ID" : "uid=0" >/dev/null
-then :
+if expr "$ID" : "uid=0" >/dev/null; then
+    :
 else
-    if [ "${PREFER_KSU}" -eq 1 ];
-    then
+    if [ "${PREFER_KSU}" -eq 1 ]; then
         # Check if we have a valid kerberos ticket
         if klist -l 1>/dev/null 2>/dev/null; then
             RUN_SUDO="ksu -q -e"
@@ -37,26 +36,24 @@
         fi
     fi

-    if [ -z "$RUN_SUDO" ]
-    then
+    if [ -z "$RUN_SUDO" ]; then
         echo "${0}: this test must run be as root, or RUN_SUDO=... " >&2
         echo "      must be set correctly in 't_server_null.rc'. SKIP." >&2
         exit "${TSERVER_NULL_SKIP_RC}"
     else
-	# Run a no-op command with privilege escalation (e.g. sudo) so that
-	# we (hopefully) do not have to ask the users password during the test.
-	if $RUN_SUDO "${KILL_EXEC}" -0 $$
-	then
-	    echo "${0}: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
-	else
-	    echo "${0}: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
-	    exit "${TSERVER_NULL_SKIP_RC}"
-	fi
+        # Run a no-op command with privilege escalation (e.g. sudo) so that
+        # we (hopefully) do not have to ask the users password during the test.
+        if $RUN_SUDO "${KILL_EXEC}" -0 $$; then
+            echo "${0}: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
+        else
+            echo "${0}: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
+            exit "${TSERVER_NULL_SKIP_RC}"
+        fi
     fi
 fi

 srcdir="${srcdir:-.}"
-export t_server_null_logdir=t_server_null-`hostname`-`date +%Y%m%d-%H%M%S`
+export t_server_null_logdir=t_server_null-$(hostname)-$(date +%Y%m%d-%H%M%S)

 # Create directory for server and client logs
 mkdir $t_server_null_logdir
diff --git a/tests/t_server_null_client.sh b/tests/t_server_null_client.sh
index 1745de5..2741d5d 100755
--- a/tests/t_server_null_client.sh
+++ b/tests/t_server_null_client.sh
@@ -3,7 +3,7 @@
 should_run_test() {
     test_name="$1"

-    if echo "$test_name"|grep -q _lwip; then
+    if echo "$test_name" | grep -q _lwip; then
         if [ "$has_lwipovpn" = "no" ]; then
             return 1
         fi
@@ -48,7 +48,7 @@

 ping_lwip_clients() {
     if [ "$has_lwipovpn" = "yes" ]; then
-        lwip_client_count=$(echo "$lwip_test_names"|wc -w|tr -d " ")
+        lwip_client_count=$(echo "$lwip_test_names" | wc -w | tr -d " ")
     else
         lwip_client_count=0
     fi
@@ -60,10 +60,10 @@
     count=0
     maxcount=10
     while [ $count -le $maxcount ]; do
-        lwip_client_ips=$(cat ./*.lwip 2>/dev/null|wc -l)
+        lwip_client_ips=$(cat ./*.lwip 2>/dev/null | wc -l)
         if [ $lwip_client_ips -lt $lwip_client_count ]; then
             echo "Waiting for LWIP clients to start up ($count/$maxcount)"
-            count=$(( count + 1))
+            count=$((count + 1))
             sleep 1
         else
             echo "$lwip_client_ips/$lwip_client_count LWIP clients up"
@@ -73,8 +73,8 @@

     wait_pids=""
     for line in $(cat ./*.lwip 2>/dev/null); do
-        target_ip=$(echo $line|cut -d "," -f 1)
-        client_pid=$(echo $line|cut -d "," -f 2)
+        target_ip=$(echo $line | cut -d "," -f 1)
+        client_pid=$(echo $line | cut -d "," -f 2)
         ping_and_kill $target_ip $client_pid &
         wait_pids="$wait_pids $!"
     done
@@ -111,7 +111,7 @@
     should_pass=$2
     log="${test_name}.log"

-    grep "Initialization Sequence Completed" "${t_server_null_logdir}/${log}" > /dev/null
+    grep "Initialization Sequence Completed" "${t_server_null_logdir}/${log}" >/dev/null
     exit_code=$?

     if [ $exit_code -eq 0 ] && [ "${should_pass}" = "yes" ]; then
@@ -144,7 +144,7 @@
 server_max_wait=15
 while [ $count -lt $server_max_wait ]; do
     servers_up=0
-    server_count=$(echo "$TEST_SERVER_LIST"|wc -w|tr -d " ")
+    server_count=$(echo "$TEST_SERVER_LIST" | wc -w | tr -d " ")

     # We need to trim single-quotes because some shells return quoted values
     # and some don't. Using "set -o posix" which would resolve this problem is
@@ -152,13 +152,13 @@
     #
     # While inactive server configurations may get checked they won't increase
     # the active server count as the processes won't be running.
-    for i in $(set|grep 'SERVER_NAME_'|cut -d "=" -f 2|tr -d "[\']"); do
-        server_pid=$(cat "$i.pid" 2> /dev/null)
-        if [ -z "$server_pid" ] ; then
+    for i in $(set | grep 'SERVER_NAME_' | cut -d "=" -f 2 | tr -d "[\']"); do
+        server_pid=$(cat "$i.pid" 2>/dev/null)
+        if [ -z "$server_pid" ]; then
             continue
         fi
-        if $RUN_SUDO kill -0 $server_pid > /dev/null 2>&1; then
-            servers_up=$(( $servers_up + 1 ))
+        if $RUN_SUDO kill -0 $server_pid >/dev/null 2>&1; then
+            servers_up=$(($servers_up + 1))
         fi
     done

@@ -168,7 +168,7 @@
         retval=0
         break
     else
-        count=$(( count + 1))
+        count=$((count + 1))
         sleep 1
     fi

@@ -199,15 +199,14 @@
 # safe to check the test results.
 test_names=""
 lwip_test_names=""
-for SUF in $TEST_RUN_LIST
-do
+for SUF in $TEST_RUN_LIST; do
     eval test_name=\"\$TEST_NAME_$SUF\"
     eval client_exec=\"\$CLIENT_EXEC_$SUF\"
     eval client_conf=\"\$CLIENT_CONF_$SUF\"

     test_names="${test_names} ${test_name}"

-    if echo "$test_name"|grep -q _lwip; then
+    if echo "$test_name" | grep -q _lwip; then
         lwip_test_names="${lwip_test_names} ${test_name}"
     fi

@@ -219,13 +218,11 @@
 ping_lwip_clients
 retval=$?

-
 # Wait until all OpenVPN clients have exited
 (wait_for_results)

 # Check test results
-for SUF in $TEST_RUN_LIST
-do
+for SUF in $TEST_RUN_LIST; do
     eval test_name=\"\$TEST_NAME_$SUF\"
     eval should_pass=\"\$SHOULD_PASS_$SUF\"

diff --git a/tests/t_server_null_server.sh b/tests/t_server_null_server.sh
index 65b7d56..327939a 100755
--- a/tests/t_server_null_server.sh
+++ b/tests/t_server_null_server.sh
@@ -13,10 +13,10 @@

     # Try to launch the server
     $RUN_SUDO "${server_exec}" \
-               $server_conf \
-               --status "${status}" 1 \
-               --writepid "${pid}" \
-               --explicit-exit-notify 3 > "$log" 2>&1 &
+        $server_conf \
+        --status "${status}" 1 \
+        --writepid "${pid}" \
+        --explicit-exit-notify 3 >"$log" 2>&1 &

     sleep 1

@@ -40,8 +40,7 @@
 retval=0

 # Launch test servers
-for SUF in $TEST_SERVER_LIST
-do
+for SUF in $TEST_SERVER_LIST; do
     eval server_name=\"\$SERVER_NAME_$SUF\"
     eval server_exec=\"\$SERVER_EXEC_$SUF\"
     eval server_conf=\"\$SERVER_CONF_$SUF\"
@@ -53,8 +52,7 @@
 # the test run.
 #
 export server_pid_files=""
-for SUF in $TEST_SERVER_LIST
-do
+for SUF in $TEST_SERVER_LIST; do
     eval server_name=\"\$SERVER_NAME_$SUF\"
     server_pid_files="${server_pid_files} ./${server_name}.pid"
 done
@@ -65,12 +63,11 @@
 count=0
 maxcount=4
 while [ $count -le $maxcount ]; do
-    if ls t_server_null_client.sh*.pid > /dev/null 2>&1
-    then
+    if ls t_server_null_client.sh*.pid >/dev/null 2>&1; then
         count=0
         sleep 1
     else
-	count=$(( count + 1))
+        count=$((count + 1))
         sleep 1
     fi
 done
@@ -81,11 +78,10 @@
 # server process does not exit in 15 seconds assume it never will, move on and
 # hope for the best.
 echo "Waiting for servers to exit"
-for PID_FILE in $server_pid_files
-do
+for PID_FILE in $server_pid_files; do
     SERVER_PID=$(cat "${PID_FILE}")

-    if [ -z "$SERVER_PID" ] ; then
+    if [ -z "$SERVER_PID" ]; then
         echo "WARNING: could not kill server ${PID_FILE}!"
         continue
     fi
@@ -95,17 +91,16 @@

     count=0
     maxcount=75
-    while [ $count -le $maxcount ]
-    do
-        $RUN_SUDO kill -0 "${SERVER_PID}" 2> /dev/null || break
-        count=$(( count + 1))
+    while [ $count -le $maxcount ]; do
+        $RUN_SUDO kill -0 "${SERVER_PID}" 2>/dev/null || break
+        count=$((count + 1))
         sleep 0.2
     done

     # If server is still up send a SIGKILL
     if [ $count -ge $maxcount ]; then
         $RUN_SUDO $KILL_EXEC -9 "${SERVER_PID}"
-        SERVER_NAME=$(basename $PID_FILE|cut -d . -f 1)
+        SERVER_NAME=$(basename $PID_FILE | cut -d . -f 1)
         echo "ERROR: had to send SIGKILL to server ${SERVER_NAME} with pid ${SERVER_PID}!"
         echo "Tail of server log:"
         tail -n 20 "${t_server_null_logdir}/${SERVER_NAME}.log"
diff --git a/tests/t_server_null_stress.sh b/tests/t_server_null_stress.sh
index 0bb9452..2fc9fde 100755
--- a/tests/t_server_null_stress.sh
+++ b/tests/t_server_null_stress.sh
@@ -7,8 +7,7 @@
 . ./t_server_null_default.rc

 export pid_files=""
-for SUF in $TEST_SERVER_LIST
-do
+for SUF in $TEST_SERVER_LIST; do
     eval server_name=\"\$SERVER_NAME_$SUF\"
     pid_files="${pid_files} ./${server_name}.pid"
 done
@@ -18,16 +17,16 @@

 count=0
 while [ $count -lt $ITERATIONS ]; do
-    count=$(( count + 1 ))
-    make check TESTS=t_server_null.sh SUBDIRS= > /dev/null 2>&1
+    count=$((count + 1))
+    make check TESTS=t_server_null.sh SUBDIRS= >/dev/null 2>&1
     retval=$?

-    echo "Iteration ${count}: return value ${retval}" >> "${LOG_BASEDIR}/make-check.log"
+    echo "Iteration ${count}: return value ${retval}" >>"${LOG_BASEDIR}/make-check.log"
     if [ $retval -ne 0 ]; then
-	DIR="${LOG_BASEDIR}/make-check-${count}"
+        DIR="${LOG_BASEDIR}/make-check-${count}"
         mkdir -p "${DIR}"
         cp t_server_null*.log "${DIR}/"
         cp test-suite.log "${DIR}/"
-        ps aux|grep openvpn|grep -vE '(suppress|grep)' > "${DIR}/psaux"
+        ps aux | grep openvpn | grep -vE '(suppress|grep)' >"${DIR}/psaux"
     fi
 done
diff --git a/tests/update_t_client_ips.sh b/tests/update_t_client_ips.sh
index 96e3826..777a286 100755
--- a/tests/update_t_client_ips.sh
+++ b/tests/update_t_client_ips.sh
@@ -5,12 +5,12 @@

 RC="$TOP_BUILDDIR/t_client_ips.rc"

-grep EXPECT_IFCONFIG4_$TESTNUM= $RC > /dev/null 2>&1
+grep EXPECT_IFCONFIG4_$TESTNUM= $RC >/dev/null 2>&1
 if [ $? -ne 0 ]; then
-    echo "EXPECT_IFCONFIG4_$TESTNUM=$ifconfig_local" >> $RC
+    echo "EXPECT_IFCONFIG4_$TESTNUM=$ifconfig_local" >>$RC
 fi

-grep EXPECT_IFCONFIG6_$TESTNUM= $RC > /dev/null 2>&1
+grep EXPECT_IFCONFIG6_$TESTNUM= $RC >/dev/null 2>&1
 if [ $? -ne 0 ]; then
-    echo "EXPECT_IFCONFIG6_$TESTNUM=$ifconfig_ipv6_local" >> $RC
+    echo "EXPECT_IFCONFIG6_$TESTNUM=$ifconfig_ipv6_local" >>$RC
 fi

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1793?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f
Gerrit-Change-Number: 1793
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <frank@lichtenheld.com>
Gerrit-Reviewer: plaisthos <arne-openvpn@rfc2549.org>
Gerrit-CC: openvpn-devel <openvpn-devel@lists.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@rfc2549.org>

[-- Attachment #1.2: Type: text/html, Size: 126832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Openvpn-devel] [L] Change in openvpn[master]: Reformat all shell-scripts with shfmt
       [not found] <gerrit.1784305303000.I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f@gerrit.openvpn.net>
  2026-07-17 16:21 ` [Openvpn-devel] [L] Change in openvpn[master]: Reformat all shell-scripts with shfmt flichtenheld (Code Review) via Openvpn-devel
@ 2026-07-22  7:29 ` plaisthos (Code Review) via Openvpn-devel
  2026-07-22 13:11 ` flichtenheld (Code Review) via Openvpn-devel
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: plaisthos (Code Review) via Openvpn-devel @ 2026-07-22  7:29 UTC (permalink / raw)
  To: flichtenheld; +Cc: plaisthos (Code Review), openvpn-devel


[-- Attachment #1.1: Type: text/plain, Size: 1142 bytes --]

Attention is currently required from: flichtenheld.

plaisthos has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1793?usp=email )

Change subject: Reformat all shell-scripts with shfmt
......................................................................


Patch Set 1: Code-Review+1

(1 comment)

Patchset:

PS1:
Looks all good to me. I don't have a strong feeling about formatting.



--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1793?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f
Gerrit-Change-Number: 1793
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <frank@lichtenheld.com>
Gerrit-Reviewer: plaisthos <arne-openvpn@rfc2549.org>
Gerrit-CC: openvpn-devel <openvpn-devel@lists.sourceforge.net>
Gerrit-Attention: flichtenheld <frank@lichtenheld.com>
Gerrit-Comment-Date: Wed, 22 Jul 2026 07:29:20 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes

[-- Attachment #1.2: Type: text/html, Size: 2349 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Openvpn-devel] [L] Change in openvpn[master]: Reformat all shell-scripts with shfmt
       [not found] <gerrit.1784305303000.I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f@gerrit.openvpn.net>
  2026-07-17 16:21 ` [Openvpn-devel] [L] Change in openvpn[master]: Reformat all shell-scripts with shfmt flichtenheld (Code Review) via Openvpn-devel
  2026-07-22  7:29 ` plaisthos (Code Review) via Openvpn-devel
@ 2026-07-22 13:11 ` flichtenheld (Code Review) via Openvpn-devel
  2026-08-18  6:31 ` razvanc (Code Review) via Openvpn-devel
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: flichtenheld (Code Review) via Openvpn-devel @ 2026-07-22 13:11 UTC (permalink / raw)
  To: plaisthos; +Cc: flichtenheld (Code Review), openvpn-devel


[-- Attachment #1.1: Type: text/plain, Size: 58640 bytes --]

Attention is currently required from: flichtenheld, plaisthos.

Hello plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1793?usp=email

to look at the new patch set (#2).

The following approvals got outdated and were removed:
Code-Review+1 by plaisthos


Change subject: Reformat all shell-scripts with shfmt
......................................................................

Reformat all shell-scripts with shfmt

According to ./dev-tools/reformat-shell.sh.

Change-Id: I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
---
M dev-tools/gen-release-tarballs.sh
M dev-tools/git-pre-commit-format.sh
M dev-tools/run-cppcheck.sh
M dev-tools/update-copyright.sh
M tests/lwip_client_up.sh
M tests/null_client_up.sh
M tests/t_client.sh.in
M tests/t_cltsrv.sh
M tests/t_lpback.sh
M tests/t_net.sh
M tests/t_server_null.sh
M tests/t_server_null_client.sh
M tests/t_server_null_server.sh
M tests/t_server_null_stress.sh
M tests/update_t_client_ips.sh
15 files changed, 412 insertions(+), 412 deletions(-)


  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/93/1793/2

diff --git a/dev-tools/gen-release-tarballs.sh b/dev-tools/gen-release-tarballs.sh
index 6071b57..78104c4 100755
--- a/dev-tools/gen-release-tarballs.sh
+++ b/dev-tools/gen-release-tarballs.sh
@@ -21,7 +21,7 @@
 if [ $# -ne 4 ]; then
     echo "Usage: $0 <remote-name> <tag-name> <sign-key> <dest-dir>"
     echo ""
-    echo "   remote-name  -- valid remotes: `git remote | tr \\\n ' '`"
+    echo "   remote-name  -- valid remotes: $(git remote | tr \\n ' ')"
     echo "   tag-name     -- An existing release tag"
     echo "   sign-key     -- PGP key used to sign all files"
     echo "   dest-dir     -- Where to put the complete set of release tarballs"
@@ -48,7 +48,7 @@
 fi

 # Extract the git URL
-giturl="`git remote get-url $arg_remote_name 2>/dev/null`"
+giturl="$(git remote get-url $arg_remote_name 2>/dev/null)"
 if [ $? -ne 0 ]; then
     echo "** ERROR ** Invalid git remote name: $arg_remote_name"
     exit 2
@@ -58,10 +58,9 @@
 echo "test" | gpg -a --clearsign -u "$arg_sign_key" 2>/dev/null 1>/dev/null
 if [ $? -ne 0 ]; then
     echo "** ERROR ** Failed when testing the PGP signing.  Wrong signing key?"
-    exit 2;
+    exit 2
 fi

-
 #
 # Helper functions
 #
@@ -70,7 +69,7 @@
 {
     local wildcard="$1"

-    res="`find . -maxdepth 1 -type f -name \"$wildcard\" | head -n1 | cut -d/ -f2-`"
+    res="$(find . -maxdepth 1 -type f -name \"$wildcard\" | head -n1 | cut -d/ -f2-)"
     if [ $? -ne 0 ]; then
         echo "-- 'find' failed."
         exit 5
@@ -87,7 +86,7 @@
     local fileext="$1"
     local dest="$2"

-    file="`get_filename openvpn-*.*.*.$fileext`"
+    file="$(get_filename openvpn-*.*.*.$fileext)"
     if [ -z "$file" ]; then
         echo "** ERROR Failed to find source file"
         exit 5
@@ -96,7 +95,7 @@
     cp "$file" "$dest"
     if [ $? -ne 0 ]; then
         echo "** ERROR ** Failed to copy $file to $destdir"
-        exit 3;
+        exit 3
     fi
 }

@@ -105,7 +104,7 @@
     local signkey="$1"
     local srchfile="$2"
     local signtype="$3"
-    local file="`get_filename $srchfile`"
+    local file="$(get_filename $srchfile)"

     echo "-- Signing $file ..."
     case "$signtype" in
@@ -126,16 +125,16 @@

         *)
             echo "** ERROR **  Unknown signing type \"$signtype\"."
-            exit 4;
+            exit 4
+            ;;
     esac

     if [ $res -ne 0 ]; then
         echo "** ERROR **  Failed to sign the file $PWD/$file"
-        exit 4;
+        exit 4
     fi
 }

-
 #
 # Preparations
 #
@@ -146,7 +145,7 @@
     /*) # Absolute path
         destdir="$arg_dest_dir/$arg_tag_name"
         ;;
-    *)  # Make absolute path from relative path
+    *) # Make absolute path from relative path
         destdir="$PWD/$arg_dest_dir/$arg_tag_name"
         ;;
 esac
@@ -168,61 +167,61 @@
 #

 # Clone the remote repository
-workdir="`mktemp -d -p /var/tmp openvpn-build-release-XXXXXX`"
+workdir="$(mktemp -d -p /var/tmp openvpn-build-release-XXXXXX)"
 cd $workdir
 echo "-- Working directory: $workdir"
 echo "-- git clone $giturl"
-git clone $giturl openvpn-gen-tarball 2> "$workdir/git-clone.log" 1>&2
+git clone $giturl openvpn-gen-tarball 2>"$workdir/git-clone.log" 1>&2
 if [ $? -ne 0 ]; then
     echo "** ERROR **  git clone failed.  See $workdir/git-clone.log for details"
-    exit 3;
+    exit 3
 fi
 cd openvpn-gen-tarball

 # Check out the proper release tag
 echo "-- Checking out tag $arg_tag_name ... "
-git checkout -b mkrelease "$arg_tag_name" 2> "$workdir/git-checkout-tag.log" 1>&2
+git checkout -b mkrelease "$arg_tag_name" 2>"$workdir/git-checkout-tag.log" 1>&2
 if [ $? -ne 0 ]; then
     echo "** ERROR **  git checkout failed.  See $workdir/git-checkout-tag.log for details"
-    exit 3;
+    exit 3
 fi

 # Prepare the source tree
 echo "-- Running autoreconf + a simple configure ... "
-(autoreconf -vi && ./configure) 2> "$workdir/autotools-prep.log" 1>&2
+(autoreconf -vi && ./configure) 2>"$workdir/autotools-prep.log" 1>&2
 if [ $? -ne 0 ]; then
     echo "** ERROR **  Failed running autotools.  See $workdir/autotools-prep.log for details"
-    exit 3;
+    exit 3
 fi

 # Generate the tar/zip files
 echo "-- Running make distcheck (generates .tar.gz) ... "
-(make distcheck) 2> "$workdir/make-distcheck.log" 1>&2
+(make distcheck) 2>"$workdir/make-distcheck.log" 1>&2
 if [ $? -ne 0 ]; then
     echo "** ERROR **  make distcheck failed.  See $workdir/make-distcheck.log for details"
-    exit 3;
+    exit 3
 fi
 copy_files tar.gz "$destdir"

 echo "-- Running make dist-xz (generates .tar.xz) ... "
-(make dist-xz) 2> "$workdir/make-dist-xz.log" 1>&2
+(make dist-xz) 2>"$workdir/make-dist-xz.log" 1>&2
 if [ $? -ne 0 ]; then
     echo "** ERROR **  make dist-xz failed.  See $workdir/make-dist-xz.log for details"
-    exit 3;
+    exit 3
 fi
 copy_files tar.xz "$destdir"

 echo "-- Running make dist-zip (generates .zip) ... "
-(make dist-zip) 2> "$workdir/make-dist-zip.log" 1>&2
+(make dist-zip) 2>"$workdir/make-dist-zip.log" 1>&2
 if [ $? -ne 0 ]; then
     echo "** ERROR **  make dist-zip failed.  See $workdir/make-dist-zip.log for details"
-    exit 3;
+    exit 3
 fi
 copy_files zip "$destdir"

 # Generate SHA256 checksums
 cd "$destdir"
-sha256sum openvpn-*.tar.{gz,xz} openvpn-*.zip > "openvpn-$arg_tag_name.sha256sum"
+sha256sum openvpn-*.tar.{gz,xz} openvpn-*.zip >"openvpn-$arg_tag_name.sha256sum"

 # Sign all the files
 echo "-- Signing files ... "
diff --git a/dev-tools/git-pre-commit-format.sh b/dev-tools/git-pre-commit-format.sh
index 9b2ecaf..3507289 100755
--- a/dev-tools/git-pre-commit-format.sh
+++ b/dev-tools/git-pre-commit-format.sh
@@ -26,7 +26,6 @@
 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-
 # git pre-commit hook that runs a stylecheck.
 # Features:
 #  - abort commit when commit does not comply with the style guidelines
@@ -43,12 +42,11 @@
 # exit on error
 set -e

-
 # If called so, install this script as pre-commit hook
-if [ "$1" = "install" ] ; then
+if [ "$1" = "install" ]; then
     TARGET="$(git rev-parse --git-path hooks)/pre-commit"

-    if [ -e "$TARGET" ] ; then
+    if [ -e "$TARGET" ]; then
         printf "$TARGET file exists. Won't overwrite.\n"
         printf "Aborting installation.\n"
         exit 1
@@ -62,18 +60,19 @@
 fi

 # check whether the given file matches any of the set extensions
-matches_extension() {
+matches_extension()
+{
     local filename="$(basename -- "$1")"
     local extension=".${filename##*.}"
     local ext

-    for ext in .c .h ; do [ "$ext" = "$extension" ] && return 0; done
+    for ext in .c .h; do [ "$ext" = "$extension" ] && return 0; done

     return 1
 }

 # necessary check for initial commit
-if git rev-parse --verify HEAD >/dev/null 2>&1 ; then
+if git rev-parse --verify HEAD >/dev/null 2>&1; then
     against=HEAD
 else
     # Initial commit: diff against an empty tree object
@@ -88,8 +87,8 @@

     # Allow to use in parallel with pre-commit
     if [ $(basename "$0") = "pre-commit.legacy" ]; then
-       echo "Skipping clang-format check in favor of pre-commit"
-       exit 0
+        echo "Skipping clang-format check in favor of pre-commit"
+        exit 0
     fi
 else
     TOOL=uncrustify
@@ -98,7 +97,7 @@
     TOOL_CMD="$TOOL_BIN -q -l C -c $UNCRUST_CONFIG"

     # make sure the config file is correctly set
-    if [ ! -f "$UNCRUST_CONFIG" ] ; then
+    if [ ! -f "$UNCRUST_CONFIG" ]; then
         printf "Error: uncrustify config file not found.\n"
         printf "Expected to find it at $UNCRUST_CONFIG.\n"
         printf "Aborting commit.\n"
@@ -106,7 +105,7 @@
     fi
 fi

-if [ -z "$TOOL_BIN" ] ; then
+if [ -z "$TOOL_BIN" ]; then
     printf "Error: $TOOL executable not found.\n"
     printf "Is it installed and in your \$PATH?\n"
     printf "Aborting commit.\n"
@@ -120,44 +119,43 @@
 # create one patch containing all changes to the files
 # sed to remove quotes around the filename, if inserted by the system
 # (done sometimes, if the filename contains special characters, like the quote itself)
-git diff-index --cached --diff-filter=ACMR --name-only $against -- | \
-sed -e 's/^"\(.*\)"$/\1/' | \
-while read file
-do
-    # ignore file if we do check for file extensions and the file
-    # does not match the extensions .c or .h
-    if ! matches_extension "$file"; then
-        continue;
-    fi
+git diff-index --cached --diff-filter=ACMR --name-only $against -- |
+    sed -e 's/^"\(.*\)"$/\1/' |
+    while read file; do
+        # ignore file if we do check for file extensions and the file
+        # does not match the extensions .c or .h
+        if ! matches_extension "$file"; then
+            continue
+        fi

-    # escape special characters in the target filename:
-    # phase 1 (characters escaped in the output diff):
-    #     - '\': backslash needs to be escaped in the output diff
-    #     - '"': quote needs to be escaped in the output diff if present inside
-    #            of the filename, as it used to bracket the entire filename part
-    # phase 2 (characters escaped in the match replacement):
-    #     - '\': backslash needs to be escaped again for sed itself
-    #            (i.e. double escaping after phase 1)
-    #     - '&': would expand to matched string
-    #     - '|': used as sed split char instead of '/'
-    # printf %s particularly important if the filename contains the % character
-    file_escaped_target=$(printf "%s" "$file" | sed -e 's/[\"]/\\&/g' -e 's/[\&|]/\\&/g')
+        # escape special characters in the target filename:
+        # phase 1 (characters escaped in the output diff):
+        #     - '\': backslash needs to be escaped in the output diff
+        #     - '"': quote needs to be escaped in the output diff if present inside
+        #            of the filename, as it used to bracket the entire filename part
+        # phase 2 (characters escaped in the match replacement):
+        #     - '\': backslash needs to be escaped again for sed itself
+        #            (i.e. double escaping after phase 1)
+        #     - '&': would expand to matched string
+        #     - '|': used as sed split char instead of '/'
+        # printf %s particularly important if the filename contains the % character
+        file_escaped_target=$(printf "%s" "$file" | sed -e 's/[\"]/\\&/g' -e 's/[\&|]/\\&/g')

-    # uncrustify our sourcefile, create a patch with diff and append it to our $patch
-    # The sed call is necessary to transform the patch from
-    #    --- - timestamp
-    #    +++ $tmpout timestamp
-    # to both lines working on the same file and having a a/ and b/ prefix.
-    # Else it can not be applied with 'git apply'.
-    git show ":$file" | $TOOL_CMD > "$tmpout"
-    git show ":$file" | diff -u -- - "$tmpout" | \
-        sed -e "1s|--- -|--- \"b/$file_escaped_target\"|" -e "2s|+++ $tmpout|+++ \"a/$file_escaped_target\"|" >> "$patch"
-done
+        # uncrustify our sourcefile, create a patch with diff and append it to our $patch
+        # The sed call is necessary to transform the patch from
+        #    --- - timestamp
+        #    +++ $tmpout timestamp
+        # to both lines working on the same file and having a a/ and b/ prefix.
+        # Else it can not be applied with 'git apply'.
+        git show ":$file" | $TOOL_CMD >"$tmpout"
+        git show ":$file" | diff -u -- - "$tmpout" |
+            sed -e "1s|--- -|--- \"b/$file_escaped_target\"|" -e "2s|+++ $tmpout|+++ \"a/$file_escaped_target\"|" >>"$patch"
+    done

 rm -f "$tmpout"

 # if no patch has been generated all is ok, clean up the file stub and exit
-if [ ! -s "$patch" ] ; then
+if [ ! -s "$patch" ]; then
     rm -f "$patch"
     exit 0
 fi
@@ -165,7 +163,7 @@
 # a patch has been created, notify the user and exit
 printf "Formatting of some code does not follow the project guidelines.\n"

-if [ $(wc -l < $patch) -gt 80 ] ; then
+if [ $(wc -l <$patch) -gt 80 ]; then
     printf "The file $patch contains the necessary fixes.\n"
 else
     printf "Here's the patch that fixes the formatting:\n\n"
diff --git a/dev-tools/run-cppcheck.sh b/dev-tools/run-cppcheck.sh
index 40db33e..a7aa3c4 100755
--- a/dev-tools/run-cppcheck.sh
+++ b/dev-tools/run-cppcheck.sh
@@ -20,24 +20,23 @@
  --check-level=exhaustive --max-configs=10 \
  --error-exitcode=1"

-
 set -x

 mkdir -p "$CPPCHECK_DIR"
 cd "${SOURCE_DIR}"
 cppcheck $COMMON_ARGS $INCLUDE_FLAGS \
-         --platform=unix64 \
-         --library=posix.cfg --library=bsd.cfg --library=gnu.cfg \
-         -U_WIN32 \
-         src/openvpn/ src/compat/ src/plugins/ sample/ \
-         tests/unit_tests/example_test/ tests/unit_tests/openvpn/ \
-         tests/unit_tests/plugins/
+    --platform=unix64 \
+    --library=posix.cfg --library=bsd.cfg --library=gnu.cfg \
+    -U_WIN32 \
+    src/openvpn/ src/compat/ src/plugins/ sample/ \
+    tests/unit_tests/example_test/ tests/unit_tests/openvpn/ \
+    tests/unit_tests/plugins/
 cppcheck $COMMON_ARGS \
-         --platform=win64 \
-         --library=windows.cfg \
-         -D_WIN32 \
-         -UTARGET_LINUX -UTARGET_FREEBSD -UTARGET_OPENBSD -UTARGET_NETBSD \
-         -UTARGET_DARWIN -UTARGET_ANDROID -UTARGET_SOLARIS -UTARGET_DRAGONFLY \
-         -UTARGET_AIX \
-         src/openvpn* src/compat/ \
-         tests/unit_tests/example_test/ tests/unit_tests/openvpn*
+    --platform=win64 \
+    --library=windows.cfg \
+    -D_WIN32 \
+    -UTARGET_LINUX -UTARGET_FREEBSD -UTARGET_OPENBSD -UTARGET_NETBSD \
+    -UTARGET_DARWIN -UTARGET_ANDROID -UTARGET_SOLARIS -UTARGET_DRAGONFLY \
+    -UTARGET_AIX \
+    src/openvpn* src/compat/ \
+    tests/unit_tests/example_test/ tests/unit_tests/openvpn*
diff --git a/dev-tools/update-copyright.sh b/dev-tools/update-copyright.sh
index 96546dd..7ca6002 100755
--- a/dev-tools/update-copyright.sh
+++ b/dev-tools/update-copyright.sh
@@ -34,8 +34,7 @@
 COPY_YEAR="$1"

 cd "$(git rev-parse --show-toplevel)"
-for file in $(git ls-files | grep -v vendor/);
-do
+for file in $(git ls-files | grep -v vendor/); do
     echo -n "Updating $file ..."
     # The first sed operation covers 20xx-20yy copyright lines,
     # The second sed operation changes 20xx -> 20xx-20yy
diff --git a/tests/lwip_client_up.sh b/tests/lwip_client_up.sh
index a6b4d24..b1941a4 100755
--- a/tests/lwip_client_up.sh
+++ b/tests/lwip_client_up.sh
@@ -2,16 +2,17 @@
 #
 # Determine the OpenVPN PID from its pid file. This works reliably even when
 # the OpenVPN process is backgrounded for parallel tests.
-MY_PPID=`cat $pid`
+MY_PPID=$(cat $pid)

 # Add this client's VPN IP and PID to a file. This enables
 # t_server_null_client.sh to kill this OpenVPN client after fping tests have
 # finished.
-echo "$ifconfig_local,$MY_PPID" >> ./$test_name.lwip
+echo "$ifconfig_local,$MY_PPID" >>./$test_name.lwip

 # Wait long enough to allow fping tests to finish. Also ensure that this
 # OpenVPN client is killed even if t_server_null_client.sh failed to do it.
-(sleep 15
-echo "ERROR: t_server_null_client.sh failed to kill OpenVPN client with PID $MY_PPID in test $test_name. Killing it in lwip_client_up.sh."
-kill -15 $MY_PPID
+(
+    sleep 15
+    echo "ERROR: t_server_null_client.sh failed to kill OpenVPN client with PID $MY_PPID in test $test_name. Killing it in lwip_client_up.sh."
+    kill -15 $MY_PPID
 ) &
diff --git a/tests/null_client_up.sh b/tests/null_client_up.sh
index d4df0c6..be339ee 100755
--- a/tests/null_client_up.sh
+++ b/tests/null_client_up.sh
@@ -4,8 +4,11 @@

 # Determine the OpenVPN PID from its pid file. This works reliably even when
 # the OpenVPN process is backgrounded for parallel tests.
-MY_PPID=`cat $pid`
+MY_PPID=$(cat $pid)

 # Allow OpenVPN to finish initializing while waiting in the background and then
 # killing the process gracefully.
-(sleep 5 ; kill -15 $MY_PPID) &
+(
+    sleep 5
+    kill -15 $MY_PPID
+) &
diff --git a/tests/t_client.sh.in b/tests/t_client.sh.in
index 7233187..98cabde 100755
--- a/tests/t_client.sh.in
+++ b/tests/t_client.sh.in
@@ -19,9 +19,9 @@
 srcdir="${srcdir:-.}"
 top_builddir="${top_builddir:-..}"
 openvpn="${openvpn:-${top_builddir}/src/openvpn/openvpn}"
-if [ -r "${top_builddir}"/t_client.rc ] ; then
+if [ -r "${top_builddir}"/t_client.rc ]; then
     . "${top_builddir}"/t_client.rc
-elif [ -r "${srcdir}"/t_client.rc ] ; then
+elif [ -r "${srcdir}"/t_client.rc ]; then
     . "${srcdir}"/t_client.rc
 else
     echo "$0: cannot find 't_client.rc' in build dir ('${top_builddir}')" >&2
@@ -32,37 +32,35 @@
 # Check for external dependencies
 FPING="fping"
 FPING6="fping6"
-which fping > /dev/null
+which fping >/dev/null
 if [ $? -ne 0 ]; then
     echo "$0: fping is not available in \$PATH" >&2
     exit "${TCLIENT_SKIP_RC}"
 fi
-which fping6 > /dev/null
+which fping6 >/dev/null
 if [ $? -ne 0 ]; then
     echo "$0: fping6 is not available in \$PATH, assuming fping 4.0 or later" >&2
     FPING="fping -4"
     FPING6="fping -6"
 fi

-KILL_EXEC=`which kill`
+KILL_EXEC=$(which kill)
 if [ $? -ne 0 ]; then
     echo "$0: kill not found in \$PATH" >&2
     exit "${TCLIENT_SKIP_RC}"
 fi

-if [ ! -x "${openvpn}" ]
-then
+if [ ! -x "${openvpn}" ]; then
     echo "no (executable) openvpn binary in current build tree. FAIL." >&2
     exit 1
 fi

-if [ ! -w . ]
-then
+if [ ! -w . ]; then
     echo "current directory is not writable (required for logging). FAIL." >&2
     exit 1
 fi

-if [ -z "$TEST_RUN_LIST" ] ; then
+if [ -z "$TEST_RUN_LIST" ]; then
     echo "TEST_RUN_LIST empty, no tests defined.  SKIP test." >&2
     exit "${TCLIENT_SKIP_RC}"
 fi
@@ -72,16 +70,14 @@

 # make sure we have permissions to run ifconfig/route from OpenVPN
 # can't use "id -u" here - doesn't work on Solaris
-ID=`id`
-if expr "$ID" : "uid=0" >/dev/null
-then :
+ID=$(id)
+if expr "$ID" : "uid=0" >/dev/null; then
+    :
 else
-    if [ "${PREFER_KSU}" -eq 1 ];
-    then
+    if [ "${PREFER_KSU}" -eq 1 ]; then
         # Check if we have a valid kerberos ticket
         klist -l 1>/dev/null 2>/dev/null
-        if [ $? -ne 0 ];
-        then
+        if [ $? -ne 0 ]; then
             # No kerberos ticket found, skip ksu and fallback to RUN_SUDO
             PREFER_KSU=0
             echo "$0: No Kerberos ticket available.  Will not use ksu."
@@ -90,8 +86,7 @@
         fi
     fi

-    if [ -z "$RUN_SUDO" ]
-    then
+    if [ -z "$RUN_SUDO" ]; then
         echo "$0: this test must run be as root, or RUN_SUDO=... " >&2
         echo "      must be set correctly in 't_client.rc'. SKIP." >&2
         exit "${TCLIENT_SKIP_RC}"
@@ -99,19 +94,18 @@
         # We have to use sudo. Make sure that we (hopefully) do not have
         # to ask the users password during the test. This is done to
         # prevent timing issues, e.g. when the waits for openvpn to start
-	if $RUN_SUDO $KILL_EXEC -0 $$
-	then
-	    echo "$0: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
-	else
-	    echo "$0: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
-	    exit "${TCLIENT_SKIP_RC}"
-	fi
+        if $RUN_SUDO $KILL_EXEC -0 $$; then
+            echo "$0: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
+        else
+            echo "$0: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
+            exit "${TCLIENT_SKIP_RC}"
+        fi
     fi
 fi

-LOGDIR=t_client-`hostname`-`date +%Y%m%d-%H%M%S`
-if mkdir $LOGDIR
-then :
+LOGDIR=t_client-$(hostname)-$(date +%Y%m%d-%H%M%S)
+if mkdir $LOGDIR; then
+    :
 else
     echo "can't create log directory '$LOGDIR'. FAIL." >&2
     exit 1
@@ -131,22 +125,29 @@
 output_start()
 {
     case $V in
-	0) outbuf="" ;;			# no per-test output at all
-	1) echo -e "$@"			# compact, details only on failure
-           outbuf="\n" ;;
-	*) echo -e "\n$@\n" ;;		# print all, with a bit formatting
+        0) outbuf="" ;; # no per-test output at all
+        1)
+            echo -e "$@" # compact, details only on failure
+            outbuf="\n"
+            ;;
+        *) echo -e "\n$@\n" ;; # print all, with a bit formatting
     esac
 }

 output()
 {
-    NO_NL=''; if [ "X$1" = "X-n" ] ; then NO_NL=$1 ; shift ; fi
+    NO_NL=''
+    if [ "X$1" = "X-n" ]; then
+        NO_NL=$1
+        shift
+    fi
     case $V in
-	0) ;;				# no per-test output at all
-	1) outbuf="$outbuf$@" 		# print details only on failure
-	   test -z "$NO_NL" && outbuf="$outbuf\n"
-           ;;
-	*) echo -e $NO_NL "$@" ;;	# print everything
+        0) ;; # no per-test output at all
+        1)
+            outbuf="$outbuf$@" # print details only on failure
+            test -z "$NO_NL" && outbuf="$outbuf\n"
+            ;;
+        *) echo -e $NO_NL "$@" ;; # print everything
     esac
 }

@@ -154,62 +155,61 @@
 fail()
 {
     output "FAIL: $@\n"
-    fail_count=$(( $fail_count + 1 ))
+    fail_count=$(($fail_count + 1))
 }

 # print "all interface IP addresses" + "all routes"
 # this is higly system dependent...
 get_ifconfig_route()
 {
-    UNAME=`uname -s`
+    UNAME=$(uname -s)
     case $UNAME in
-	Linux)
+        Linux)
             # linux / iproute2? (-> if configure got a path)
-            if [ -n "@IPROUTE@" ]
-            then
+            if [ -n "@IPROUTE@" ]; then
                 echo "-- linux iproute2 --"
-                @IPROUTE@ addr show     | grep -v valid_lft
+                @IPROUTE@ addr show | grep -v valid_lft
                 @IPROUTE@ route show
                 @IPROUTE@ -o -6 route show | grep -v ' cache' | sed -E -e 's/ expires [0-9]*sec//' -e 's/ (mtu|hoplimit|cwnd|ssthresh) [0-9]+//g' -e 's/ (rtt|rttvar) [0-9]+ms//g'
             else
-	        echo "-- linux / ifconfig --"
-	        LANG=C @IFCONFIG@ -a |egrep  "( addr:|encap:)"
-	        LANG=C @NETSTAT@ -rn -4 -6
+                echo "-- linux / ifconfig --"
+                LANG=C @IFCONFIG@ -a | egrep "( addr:|encap:)"
+                LANG=C @NETSTAT@ -rn -4 -6
             fi
             ;;
-	FreeBSD|NetBSD|Darwin)
-	   echo "-- FreeBSD/NetBSD/Darwin [MacOS X] --"
-	   @IFCONFIG@ -a | egrep "(flags=|inet)"
-	   @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
-	   ;;
-	OpenBSD)
-	   echo "-- OpenBSD --"
-	   @IFCONFIG@ -a | egrep "(flags=|inet)" | \
-		sed -e 's/pltime [0-9]*//' -e 's/vltime [0-9]*//'
-	   @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
-	   ;;
-	SunOS)
-	   echo "-- Solaris --"
-	   @IFCONFIG@ -a | egrep "(flags=|inet)"
-	   @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
-	   ;;
-	AIX)
-	   echo "-- AIX --"
-	   @IFCONFIG@ -a | egrep "(flags=|inet)"
-	   @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
-	   ;;
+        FreeBSD | NetBSD | Darwin)
+            echo "-- FreeBSD/NetBSD/Darwin [MacOS X] --"
+            @IFCONFIG@ -a | egrep "(flags=|inet)"
+            @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
+            ;;
+        OpenBSD)
+            echo "-- OpenBSD --"
+            @IFCONFIG@ -a | egrep "(flags=|inet)" |
+                sed -e 's/pltime [0-9]*//' -e 's/vltime [0-9]*//'
+            @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
+            ;;
+        SunOS)
+            echo "-- Solaris --"
+            @IFCONFIG@ -a | egrep "(flags=|inet)"
+            @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
+            ;;
+        AIX)
+            echo "-- AIX --"
+            @IFCONFIG@ -a | egrep "(flags=|inet)"
+            @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
+            ;;
         *)
-           echo "get_ifconfig_route(): no idea how to get info on your OS (`uname -s`).  FAIL." >&2
-           exit 20
-           ;;
+            echo "get_ifconfig_route(): no idea how to get info on your OS ($(uname -s)).  FAIL." >&2
+            exit 20
+            ;;
     esac

     # another round of per-platform information gathering, for DNS info
     # for most of the platforms "cat /etc/resolv.conf" is good enough
     # except Linux and MacOS
     case $UNAME in
-	Linux)
-            if [ -x /usr/bin/resolvectl -a -d /run/systemd/system ] ; then
+        Linux)
+            if [ -x /usr/bin/resolvectl -a -d /run/systemd/system ]; then
                 echo "-- linux resolvectl --"
                 resolvectl status
             else
@@ -217,7 +217,7 @@
                 cat /etc/resolv.conf
             fi
             ;;
-	Darwin)
+        Darwin)
             echo "-- MacOS scutil --dns"
             scutil --dns
             ;;
@@ -234,19 +234,19 @@
 #  arg2: IPv4/IPv6 address that must show up in out of "get_ifconfig_route"
 check_ifconfig()
 {
-    proto=$1 ; shift
+    proto=$1
+    shift
     expect_list="$@"

-    if [ -z "$expect_list" ] ; then return ; fi
-    if [ "$expect_list" = "-" ] ; then return ; fi
+    if [ -z "$expect_list" ]; then return; fi
+    if [ "$expect_list" = "-" ]; then return; fi

-    for expect in $expect_list
-    do
-	if get_ifconfig_route | fgrep "$expect" >/dev/null
-	then :
-	else
-	    fail "check_ifconfig(): expected IPv$proto address '$expect' not found in ifconfig output."
-	fi
+    for expect in $expect_list; do
+        if get_ifconfig_route | fgrep "$expect" >/dev/null; then
+            :
+        else
+            fail "check_ifconfig(): expected IPv$proto address '$expect' not found in ifconfig output."
+        fi
     done
 }

@@ -257,47 +257,48 @@
 #  arg3... -> fping arguments (host list)
 run_ping_tests()
 {
-    proto=$1 ; want=$2 ; shift ; shift
+    proto=$1
+    want=$2
+    shift
+    shift
     targetlist="$@"

     # "no targets" is fine
-    if [ -z "$targetlist" ] ; then return ; fi
+    if [ -z "$targetlist" ]; then return; fi

     case $proto in
-	4) cmd="$FPING" ;;
-	6) cmd="$FPING6" ;;
-	*) echo "internal error in run_ping_tests arg 1: '$proto'" >&2
-	   exit 1 ;;
+        4) cmd="$FPING" ;;
+        6) cmd="$FPING6" ;;
+        *)
+            echo "internal error in run_ping_tests arg 1: '$proto'" >&2
+            exit 1
+            ;;
     esac

     case $want in
-	want_ok)   sizes_list="64 1440 3000" ;;
-	want_fail) sizes_list="64" ;;
+        want_ok) sizes_list="64 1440 3000" ;;
+        want_fail) sizes_list="64" ;;
     esac

-    for bytes in $sizes_list
-    do
-	output "run IPv$proto ping tests ($want), $bytes byte packets..."
+    for bytes in $sizes_list; do
+        output "run IPv$proto ping tests ($want), $bytes byte packets..."

-	echo "$cmd -b $bytes -C 20 -p 250 -q $fping_args $targetlist" >>$LOGDIR/$SUF:fping.out
-	$cmd -b $bytes -C 20 -p 250 -q $fping_args $targetlist >>$LOGDIR/$SUF:fping.out 2>&1
+        echo "$cmd -b $bytes -C 20 -p 250 -q $fping_args $targetlist" >>$LOGDIR/$SUF:fping.out
+        $cmd -b $bytes -C 20 -p 250 -q $fping_args $targetlist >>$LOGDIR/$SUF:fping.out 2>&1

-	# while OpenVPN is running, pings must succeed (want='want_ok')
-	# before OpenVPN is up, pings must NOT succeed (want='want_fail')
+        # while OpenVPN is running, pings must succeed (want='want_ok')
+        # before OpenVPN is up, pings must NOT succeed (want='want_fail')

-	rc=$?
-	if [ $rc = 0 ] 				# all ping OK
-	then
-	    if [ $want = "want_fail" ]		# not what we want
-	    then
-		fail "IPv$proto ping test succeeded, but needs to *fail*."
-	    fi
-	else					# ping failed
-	    if [ $want = "want_ok" ]		# not what we wanted
-	    then
-		fail "IPv$proto ping test ($bytes bytes) failed, but should succeed."
-	    fi
-	fi
+        rc=$?
+        if [ $rc = 0 ]; then                 # all ping OK
+            if [ $want = "want_fail" ]; then # not what we want
+                fail "IPv$proto ping test succeeded, but needs to *fail*."
+            fi
+        else                               # ping failed
+            if [ $want = "want_ok" ]; then # not what we wanted
+                fail "IPv$proto ping test ($bytes bytes) failed, but should succeed."
+            fi
+        fi
     done
 }

@@ -308,8 +309,7 @@
 SUMMARY_SKIP=
 SUMMARY_FAIL=

-for SUF in $TEST_RUN_LIST
-do
+for SUF in $TEST_RUN_LIST; do
     # get config variables
     eval test_prep=\"\$PREPARE_$SUF\"
     eval test_check_skip=\"\$CHECK_SKIP_$SUF\"
@@ -336,11 +336,13 @@

     if [ -n "$test_check_skip" ]; then
         output "check whether we need to skip: '$test_check_skip'"
-        if eval $test_check_skip; then :
+        if eval $test_check_skip; then
+            :
         else
             output "skip check failed, SKIP test $SUF."
-	    SUMMARY_SKIP="$SUMMARY_SKIP $SUF"
-	    echo -e "$outbuf" ; continue
+            SUMMARY_SKIP="$SUMMARY_SKIP $SUF"
+            echo -e "$outbuf"
+            continue
         fi
     fi

@@ -355,13 +357,14 @@
     output "\nrun pre-openvpn ping tests - targets must not be reachable..."
     run_ping_tests 4 want_fail "$ping4_hosts"
     run_ping_tests 6 want_fail "$ping6_hosts"
-    if [ "$fail_count" = 0 ] ; then
+    if [ "$fail_count" = 0 ]; then
         output "OK.\n"
     else
-	fail "make sure that ping hosts are ONLY reachable via VPN, SKIP test $SUF."
-	SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
-	exit_code=31
-	echo -e "$outbuf" ; continue
+        fail "make sure that ping hosts are ONLY reachable via VPN, SKIP test $SUF."
+        SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
+        exit_code=31
+        echo -e "$outbuf"
+        continue
     fi

     pidfile="${top_builddir}/tests/$LOGDIR/openvpn-$SUF.pid"
@@ -376,18 +379,17 @@
     # to $ovpn_init_check times.
     ovpn_init_check=30
     ovpn_init_success=0
-    while [ $ovpn_init_check -gt 0 ];
-    do
-       sleep 1  # Wait for OpenVPN to initialize and have had time to write the pid file
-       grep "Initialization Sequence Completed" $LOGDIR/$SUF:openvpn.log >/dev/null
-       if [ $? -eq 0 ]; then
-           ovpn_init_check=0
-           ovpn_init_success=1
-       fi
-       ovpn_init_check=$(( $ovpn_init_check - 1 ))
+    while [ $ovpn_init_check -gt 0 ]; do
+        sleep 1 # Wait for OpenVPN to initialize and have had time to write the pid file
+        grep "Initialization Sequence Completed" $LOGDIR/$SUF:openvpn.log >/dev/null
+        if [ $? -eq 0 ]; then
+            ovpn_init_check=0
+            ovpn_init_success=1
+        fi
+        ovpn_init_check=$(($ovpn_init_check - 1))
     done

-    opid=`cat $pidfile`
+    opid=$(cat $pidfile)
     if [ -n "$opid" ]; then
         output "  OpenVPN running with PID $opid"
     else
@@ -398,16 +400,17 @@
     if [ $ovpn_init_success -ne 1 -o -z "$opid" ]; then
         output "$0:  OpenVPN did not initialize in a reasonable time"
         if [ -n "$opid" ]; then
-           $RUN_SUDO $KILL_EXEC $opid
+            $RUN_SUDO $KILL_EXEC $opid
         fi
         $RUN_SUDO $KILL_EXEC $sudopid
-	output "tail -5 $SUF:openvpn.log"
-	output "`tail -5 $LOGDIR/$SUF:openvpn.log`"
-	fail "skip rest of sub-tests for test run $SUF."
-	trap - 0 1 2 3 15
-	SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
-	exit_code=30
-	echo -e "$outbuf" ; continue
+        output "tail -5 $SUF:openvpn.log"
+        output "$(tail -5 $LOGDIR/$SUF:openvpn.log)"
+        fail "skip rest of sub-tests for test run $SUF."
+        trap - 0 1 2 3 15
+        SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
+        exit_code=30
+        echo -e "$outbuf"
+        continue
     fi

     # make sure openvpn client is terminated in case shell exits
@@ -418,17 +421,16 @@
     output "save ifconfig+route"
     get_ifconfig_route >$LOGDIR/$SUF:ifconfig_route.txt

-    if [ "$expect_ifconfig4" = "-" ] ; then
+    if [ "$expect_ifconfig4" = "-" ]; then
         output "skip ifconfig+route check"
     else
-	output -n "compare pre-openvpn ifconfig+route with current values..."
-	if diff $LOGDIR/$SUF:ifconfig_route_pre.txt \
-		$LOGDIR/$SUF:ifconfig_route.txt >/dev/null
-	then
-	    fail "no differences between ifconfig/route before OpenVPN start and now."
-	else
-	    output " OK!\n"
-	fi
+        output -n "compare pre-openvpn ifconfig+route with current values..."
+        if diff $LOGDIR/$SUF:ifconfig_route_pre.txt \
+            $LOGDIR/$SUF:ifconfig_route.txt >/dev/null; then
+            fail "no differences between ifconfig/route before OpenVPN start and now."
+        else
+            output " OK!\n"
+        fi
     fi

     # post init script needed?
@@ -449,8 +451,8 @@
     $RUN_SUDO $KILL_EXEC $opid
     wait $!
     rc=$?
-    if [ $rc != 0 ] ; then
-	fail "OpenVPN return code $rc, expect 0"
+    if [ $rc != 0 ]; then
+        fail "OpenVPN return code $rc, expect 0"
     fi

     output "\nsave post-openvpn ifconfig + route..."
@@ -458,23 +460,22 @@

     output -n "compare pre- and post-openvpn ifconfig + route..."
     if diff $LOGDIR/$SUF:ifconfig_route_pre.txt \
-	    $LOGDIR/$SUF:ifconfig_route_post.txt >$LOGDIR/$SUF:ifconfig_route_diff.txt
-    then
-	output " OK.\n"
+        $LOGDIR/$SUF:ifconfig_route_post.txt >$LOGDIR/$SUF:ifconfig_route_diff.txt; then
+        output " OK.\n"
     else
-	output "\n\n" "`cat $LOGDIR/$SUF:ifconfig_route_diff.txt`" "\n"
-	fail "differences between pre- and post-ifconfig/route."
+        output "\n\n" "$(cat $LOGDIR/$SUF:ifconfig_route_diff.txt)" "\n"
+        fail "differences between pre- and post-ifconfig/route."
     fi
-    if [ "$fail_count" = 0 ] ; then
+    if [ "$fail_count" = 0 ]; then
         output "test run $SUF: all tests OK.\n"
-	SUMMARY_OK="$SUMMARY_OK $SUF"
+        SUMMARY_OK="$SUMMARY_OK $SUF"
     else
-	if [ "$V" -gt 0 ] ; then
-	    echo -e -n "$outbuf"
-	    echo -e "test run $SUF: $fail_count test failures. FAIL.\n"
+        if [ "$V" -gt 0 ]; then
+            echo -e -n "$outbuf"
+            echo -e "test run $SUF: $fail_count test failures. FAIL.\n"
         fi
-	SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
-	exit_code=30
+        SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
+        exit_code=30
     fi

     if [ -n "$test_cleanup" ]; then
@@ -484,9 +485,9 @@

 done

-if [ -z "$SUMMARY_OK" ] ; then SUMMARY_OK=" none"; fi
-if [ -z "$SUMMARY_SKIP" ] ; then SUMMARY_SKIP=" none"; fi
-if [ -z "$SUMMARY_FAIL" ] ; then SUMMARY_FAIL=" none"; fi
+if [ -z "$SUMMARY_OK" ]; then SUMMARY_OK=" none"; fi
+if [ -z "$SUMMARY_SKIP" ]; then SUMMARY_SKIP=" none"; fi
+if [ -z "$SUMMARY_FAIL" ]; then SUMMARY_FAIL=" none"; fi
 echo "Test sets succeeded:$SUMMARY_OK."
 echo "Test sets skipped:$SUMMARY_SKIP."
 echo "Test sets failed:$SUMMARY_FAIL."
diff --git a/tests/t_cltsrv.sh b/tests/t_cltsrv.sh
index 6b7df65..03c3845 100755
--- a/tests/t_cltsrv.sh
+++ b/tests/t_cltsrv.sh
@@ -24,50 +24,58 @@
 trap "rm -f log.$$ log.$$.signal ; trap 0 ; exit 77" 1 2 15
 trap "rm -f log.$$ log.$$.signal ; exit 1" 0 3
 addopts=
-case `uname -s` in
+case $(uname -s) in
     FreeBSD)
-    # FreeBSD jails map the outgoing IP to the jail IP - we need to
-    # allow the real IP unless we want the test to run forever.
-    if test "`sysctl 2>/dev/null -n security.jail.jailed`" = 1 \
-    || ps -ostate= -p $$ | grep -q J; then
-	addopts="--float"
-	if test "x`ifconfig | grep inet`" = x ; then
-	    echo "###"
-	    echo "### To run the test in a FreeBSD jail, you MUST add an IP alias for the jail's IP."
-	    echo "###"
-	    exit 77
-	fi
-    fi
-    ;;
+        # FreeBSD jails map the outgoing IP to the jail IP - we need to
+        # allow the real IP unless we want the test to run forever.
+        if test "$(sysctl 2>/dev/null -n security.jail.jailed)" = 1 ||
+            ps -ostate= -p $$ | grep -q J; then
+            addopts="--float"
+            if test "x$(ifconfig | grep inet)" = x; then
+                echo "###"
+                echo "### To run the test in a FreeBSD jail, you MUST add an IP alias for the jail's IP."
+                echo "###"
+                exit 77
+            fi
+        fi
+        ;;
 esac

 # make sure that the --down script is executable -- fail (rather than
 # skip) test if it isn't.
 downscript="../tests/t_cltsrv-down.sh"
 root="${top_srcdir}/sample"
-test -x "${root}/${downscript}" || chmod +x "${root}/${downscript}" || { echo >&2 "${root}/${downscript} is not executable, failing." ; exit 1 ; }
+test -x "${root}/${downscript}" || chmod +x "${root}/${downscript}" || {
+    echo >&2 "${root}/${downscript} is not executable, failing."
+    exit 1
+}
 echo "The following test will take about two minutes." >&2
 echo "If the addresses are in use, this test will retry up to two times." >&2

 # go
 success=0
-for i in 1 2 3 ; do
-  set +e
-  (
-  "${openvpn}" --script-security 2 --cd "${root}" ${addopts} --setenv role srv --down "${downscript}" --tls-exit --ping-exit 180 --config "sample-config-files/loopback-server" &
-  "${openvpn}" --script-security 2 --cd "${top_srcdir}/sample" ${addopts} --setenv role clt --down "${downscript}" --tls-exit --ping-exit 180 --config "sample-config-files/loopback-client"
-  ) 3>log.$$.signal >log.$$ 2>&1
-  e1=$?
-  wait $!
-  e2=$?
-  grep 'TCP/UDP: Socket bind failed on local address.*in use' log.$$ >/dev/null && {
-    echo 'address in use, retrying in 150 s'
-    sleep 150
-    continue
-  }
-  grep -v ':inactive$' log.$$.signal >/dev/null && { cat log.$$.signal ; echo ; cat log.$$ ; exit 1 ; }
-  success=1
-  break
+for i in 1 2 3; do
+    set +e
+    (
+        "${openvpn}" --script-security 2 --cd "${root}" ${addopts} --setenv role srv --down "${downscript}" --tls-exit --ping-exit 180 --config "sample-config-files/loopback-server" &
+        "${openvpn}" --script-security 2 --cd "${top_srcdir}/sample" ${addopts} --setenv role clt --down "${downscript}" --tls-exit --ping-exit 180 --config "sample-config-files/loopback-client"
+    ) 3>log.$$.signal >log.$$ 2>&1
+    e1=$?
+    wait $!
+    e2=$?
+    grep 'TCP/UDP: Socket bind failed on local address.*in use' log.$$ >/dev/null && {
+        echo 'address in use, retrying in 150 s'
+        sleep 150
+        continue
+    }
+    grep -v ':inactive$' log.$$.signal >/dev/null && {
+        cat log.$$.signal
+        echo
+        cat log.$$
+        exit 1
+    }
+    success=1
+    break
 done

 set -e
@@ -75,14 +83,14 @@
 # exit code - defaults to 0, PASS
 ec=0

-if [ $success != 1 ] ; then
-  # couldn't run test -- addresses in use, skip test
-  cat log.$$
-  ec=77
-elif [ $e1 != 0 ] || [ $e2 != 0 ] ; then
-  # failure -- fail test
-  cat log.$$
-  ec=1
+if [ $success != 1 ]; then
+    # couldn't run test -- addresses in use, skip test
+    cat log.$$
+    ec=77
+elif [ $e1 != 0 ] || [ $e2 != 0 ]; then
+    # failure -- fail test
+    cat log.$$
+    ec=1
 fi

 rm log.$$ log.$$.signal
diff --git a/tests/t_lpback.sh b/tests/t_lpback.sh
index 6802506..058206f 100755
--- a/tests/t_lpback.sh
+++ b/tests/t_lpback.sh
@@ -37,51 +37,56 @@
 test_start()
 {
     case $V in
-        0) outbuf="" ;;                  # no per-test output at all
-        1) outbuf="$@" ;;                # compact, details only on failure
-        *) printf "$@" ;;                # print all
+        0) outbuf="" ;;   # no per-test output at all
+        1) outbuf="$@" ;; # compact, details only on failure
+        *) printf "$@" ;; # print all
     esac
 }
 test_end()
 {
-    RC=$1 ; LOG=$2
-    if [ $RC != 0 ]
-    then
+    RC=$1
+    LOG=$2
+    if [ $RC != 0 ]; then
         case $V in
-            0) ;;                                # no per-test output
-            1) echo "$outbuf" "FAIL (RC=$RC)"; cat $LOG ;;
-            *) echo "FAIL (RC=$RC)"; cat $LOG ;;
+            0) ;; # no per-test output
+            1)
+                echo "$outbuf" "FAIL (RC=$RC)"
+                cat $LOG
+                ;;
+            *)
+                echo "FAIL (RC=$RC)"
+                cat $LOG
+                ;;
         esac
         e=1
-        tests_failed=$(( $tests_failed + 1 ))
+        tests_failed=$(($tests_failed + 1))
     else
         case $V in
-            0|1) ;;                              # no per-test output for 'OK'
-            *) echo "OK"                         # print all
+            0 | 1) ;;       # no per-test output for 'OK'
+            *) echo "OK" ;; # print all
         esac
-        tests_passed=$(( $tests_passed + 1 ))
+        tests_passed=$(($tests_passed + 1))
     fi
 }

 # if running with V=1, give an indication what test runs now
-if [ "$V" = 1  ] ; then
+if [ "$V" = 1 ]; then
     echo "$0: running with V=$V, only printing test fails"
 fi

-
 # Get list of supported ciphers from openvpn --show-ciphers output
-CIPHERS=$(${openvpn} --show-ciphers | \
-            sed -e '/The following/,/^$/d' -e s'/ .*//' -e '/^[[:space:]]*$/d')
+CIPHERS=$(${openvpn} --show-ciphers |
+    sed -e '/The following/,/^$/d' -e s'/ .*//' -e '/^[[:space:]]*$/d')

 # SK, 2014-06-04: currently the DES-EDE3-CFB1 implementation of OpenSSL is
 # broken (see http://rt.openssl.org/Ticket/Display.html?id=2867), so exclude
 # that cipher from this test.
 # GD, 2014-07-06 so is DES-CFB1
 # GD, 2014-07-06 do not test RC5-* either (fails on NetBSD w/o libcrypto_rc5)
-CIPHERS=$(echo "$CIPHERS" | egrep -v '^(DES-EDE3-CFB1|DES-CFB1|RC5-)' )
+CIPHERS=$(echo "$CIPHERS" | egrep -v '^(DES-EDE3-CFB1|DES-CFB1|RC5-)')

 e=0
-if [ -z "$CIPHERS" ] ; then
+if [ -z "$CIPHERS" ]; then
     echo "'openvpn --show-ciphers' FAILED (empty list)"
     e=1
 fi
@@ -91,10 +96,9 @@

 set +e

-for cipher in ${CIPHERS}
-do
+for cipher in ${CIPHERS}; do
     test_start "Testing cipher ${cipher}... "
-    ( "${openvpn}" --test-crypto --cipher ${cipher} ) >log.$$ 2>&1
+    ("${openvpn}" --test-crypto --cipher ${cipher}) >log.$$ 2>&1
     test_end $? log.$$
 done

@@ -121,7 +125,7 @@
     >log.$$ 2>&1
 test_end $? log.$$

-if [ "$V" -ge 1  ] ; then
+if [ "$V" -ge 1 ]; then
     echo "$0: tests passed: $tests_passed  failed: $tests_failed"
 fi

diff --git a/tests/t_net.sh b/tests/t_net.sh
index 8134832..17e028e 100755
--- a/tests/t_net.sh
+++ b/tests/t_net.sh
@@ -9,7 +9,6 @@
 top_builddir="${top_builddir:-..}"
 openvpn="${openvpn:-${top_builddir}/src/openvpn/openvpn}"

-
 # bail out right away on non-linux. NetLink (the object of this test) is only
 # used on Linux, therefore testing other platform is not needed.
 #
@@ -69,7 +68,6 @@
     done
 }

-
 ## execution starts here

 # t_client.rc required only for RUN_SUDO definition
@@ -89,21 +87,18 @@
     exit 77
 fi

-
 # Ensure PREFER_KSU is in a known state
 PREFER_KSU="${PREFER_KSU:-0}"

 # make sure we have permissions to run the networking unit-test
-ID=`id`
-if expr "$ID" : "uid=0" >/dev/null
-then :
+ID=$(id)
+if expr "$ID" : "uid=0" >/dev/null; then
+    :
 else
-    if [ "${PREFER_KSU}" -eq 1 ];
-    then
+    if [ "${PREFER_KSU}" -eq 1 ]; then
         # Check if we have a valid kerberos ticket
         klist -l 1>/dev/null 2>/dev/null
-        if [ $? -ne 0 ];
-        then
+        if [ $? -ne 0 ]; then
             # No kerberos ticket found, skip ksu and fallback to RUN_SUDO
             PREFER_KSU=0
             echo "$0: No Kerberos ticket available.  Will not use ksu."
@@ -112,16 +107,14 @@
         fi
     fi

-    if [ -z "$RUN_SUDO" ]
-    then
+    if [ -z "$RUN_SUDO" ]; then
         echo "$0: no RUN_SUDO=... in t_client.rc or environment, defaulting to 'sudo'." >&2
         echo "      if that does not work, set RUN_SUDO= correctly for your system." >&2
         RUN_SUDO="sudo"
     fi

     # check that we can run the unit-test binary with sudo
-    if $RUN_SUDO $UNIT_TEST test
-    then
+    if $RUN_SUDO $UNIT_TEST test; then
         echo "$0: $RUN_SUDO $UNIT_TEST succeeded, good."
     else
         echo "$0: $RUN_SUDO $UNIT_TEST failed, cannot go on. SKIP." >&2
diff --git a/tests/t_server_null.sh b/tests/t_server_null.sh
index 74ffd52..c633614 100755
--- a/tests/t_server_null.sh
+++ b/tests/t_server_null.sh
@@ -2,7 +2,7 @@
 #
 TSERVER_NULL_SKIP_RC="${TSERVER_NULL_SKIP_RC:-77}"

-if ! [ -r "./t_server_null.rc" ] ; then
+if ! [ -r "./t_server_null.rc" ]; then
     echo "${0}: cannot find './t_server_null.rc. SKIPPING TEST.'" >&2
     exit "${TSERVER_NULL_SKIP_RC}"
 fi
@@ -22,11 +22,10 @@
 # make sure we have permissions to run ifconfig/route from OpenVPN
 # can't use "id -u" here - doesn't work on Solaris
 ID=$(id)
-if expr "$ID" : "uid=0" >/dev/null
-then :
+if expr "$ID" : "uid=0" >/dev/null; then
+    :
 else
-    if [ "${PREFER_KSU}" -eq 1 ];
-    then
+    if [ "${PREFER_KSU}" -eq 1 ]; then
         # Check if we have a valid kerberos ticket
         if klist -l 1>/dev/null 2>/dev/null; then
             RUN_SUDO="ksu -q -e"
@@ -37,26 +36,24 @@
         fi
     fi

-    if [ -z "$RUN_SUDO" ]
-    then
+    if [ -z "$RUN_SUDO" ]; then
         echo "${0}: this test must run be as root, or RUN_SUDO=... " >&2
         echo "      must be set correctly in 't_server_null.rc'. SKIP." >&2
         exit "${TSERVER_NULL_SKIP_RC}"
     else
-	# Run a no-op command with privilege escalation (e.g. sudo) so that
-	# we (hopefully) do not have to ask the users password during the test.
-	if $RUN_SUDO "${KILL_EXEC}" -0 $$
-	then
-	    echo "${0}: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
-	else
-	    echo "${0}: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
-	    exit "${TSERVER_NULL_SKIP_RC}"
-	fi
+        # Run a no-op command with privilege escalation (e.g. sudo) so that
+        # we (hopefully) do not have to ask the users password during the test.
+        if $RUN_SUDO "${KILL_EXEC}" -0 $$; then
+            echo "${0}: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
+        else
+            echo "${0}: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
+            exit "${TSERVER_NULL_SKIP_RC}"
+        fi
     fi
 fi

 srcdir="${srcdir:-.}"
-export t_server_null_logdir=t_server_null-`hostname`-`date +%Y%m%d-%H%M%S`
+export t_server_null_logdir=t_server_null-$(hostname)-$(date +%Y%m%d-%H%M%S)

 # Create directory for server and client logs
 mkdir $t_server_null_logdir
diff --git a/tests/t_server_null_client.sh b/tests/t_server_null_client.sh
index 1745de5..3203cc2 100755
--- a/tests/t_server_null_client.sh
+++ b/tests/t_server_null_client.sh
@@ -1,9 +1,10 @@
 #!/bin/sh

-should_run_test() {
+should_run_test()
+{
     test_name="$1"

-    if echo "$test_name"|grep -q _lwip; then
+    if echo "$test_name" | grep -q _lwip; then
         if [ "$has_lwipovpn" = "no" ]; then
             return 1
         fi
@@ -12,7 +13,8 @@
     return 0
 }

-launch_client() {
+launch_client()
+{
     test_name=$1
     log="${test_name}.log"
     pid="${test_name}.pid"
@@ -30,7 +32,8 @@
         --log "${t_server_null_logdir}/${log}" &
 }

-ping_and_kill() {
+ping_and_kill()
+{
     if fping -q -c 5 $1; then
         echo "PASS: fping lwipovpn client $target"
     else
@@ -46,9 +49,10 @@
     kill -15 $2
 }

-ping_lwip_clients() {
+ping_lwip_clients()
+{
     if [ "$has_lwipovpn" = "yes" ]; then
-        lwip_client_count=$(echo "$lwip_test_names"|wc -w|tr -d " ")
+        lwip_client_count=$(echo "$lwip_test_names" | wc -w | tr -d " ")
     else
         lwip_client_count=0
     fi
@@ -60,10 +64,10 @@
     count=0
     maxcount=10
     while [ $count -le $maxcount ]; do
-        lwip_client_ips=$(cat ./*.lwip 2>/dev/null|wc -l)
+        lwip_client_ips=$(cat ./*.lwip 2>/dev/null | wc -l)
         if [ $lwip_client_ips -lt $lwip_client_count ]; then
             echo "Waiting for LWIP clients to start up ($count/$maxcount)"
-            count=$(( count + 1))
+            count=$((count + 1))
             sleep 1
         else
             echo "$lwip_client_ips/$lwip_client_count LWIP clients up"
@@ -73,8 +77,8 @@

     wait_pids=""
     for line in $(cat ./*.lwip 2>/dev/null); do
-        target_ip=$(echo $line|cut -d "," -f 1)
-        client_pid=$(echo $line|cut -d "," -f 2)
+        target_ip=$(echo $line | cut -d "," -f 1)
+        client_pid=$(echo $line | cut -d "," -f 2)
         ping_and_kill $target_ip $client_pid &
         wait_pids="$wait_pids $!"
     done
@@ -84,7 +88,8 @@
     test -e ./lwip_failed && return 1 || return 0
 }

-wait_for_results() {
+wait_for_results()
+{
     tests_running="yes"

     # Wait a bit to allow an OpenVPN client process to create a pidfile to
@@ -106,12 +111,13 @@
     done
 }

-get_client_test_result() {
+get_client_test_result()
+{
     test_name=$1
     should_pass=$2
     log="${test_name}.log"

-    grep "Initialization Sequence Completed" "${t_server_null_logdir}/${log}" > /dev/null
+    grep "Initialization Sequence Completed" "${t_server_null_logdir}/${log}" >/dev/null
     exit_code=$?

     if [ $exit_code -eq 0 ] && [ "${should_pass}" = "yes" ]; then
@@ -144,7 +150,7 @@
 server_max_wait=15
 while [ $count -lt $server_max_wait ]; do
     servers_up=0
-    server_count=$(echo "$TEST_SERVER_LIST"|wc -w|tr -d " ")
+    server_count=$(echo "$TEST_SERVER_LIST" | wc -w | tr -d " ")

     # We need to trim single-quotes because some shells return quoted values
     # and some don't. Using "set -o posix" which would resolve this problem is
@@ -152,13 +158,13 @@
     #
     # While inactive server configurations may get checked they won't increase
     # the active server count as the processes won't be running.
-    for i in $(set|grep 'SERVER_NAME_'|cut -d "=" -f 2|tr -d "[\']"); do
-        server_pid=$(cat "$i.pid" 2> /dev/null)
-        if [ -z "$server_pid" ] ; then
+    for i in $(set | grep 'SERVER_NAME_' | cut -d "=" -f 2 | tr -d "[\']"); do
+        server_pid=$(cat "$i.pid" 2>/dev/null)
+        if [ -z "$server_pid" ]; then
             continue
         fi
-        if $RUN_SUDO kill -0 $server_pid > /dev/null 2>&1; then
-            servers_up=$(( $servers_up + 1 ))
+        if $RUN_SUDO kill -0 $server_pid >/dev/null 2>&1; then
+            servers_up=$(($servers_up + 1))
         fi
     done

@@ -168,7 +174,7 @@
         retval=0
         break
     else
-        count=$(( count + 1))
+        count=$((count + 1))
         sleep 1
     fi

@@ -199,15 +205,14 @@
 # safe to check the test results.
 test_names=""
 lwip_test_names=""
-for SUF in $TEST_RUN_LIST
-do
+for SUF in $TEST_RUN_LIST; do
     eval test_name=\"\$TEST_NAME_$SUF\"
     eval client_exec=\"\$CLIENT_EXEC_$SUF\"
     eval client_conf=\"\$CLIENT_CONF_$SUF\"

     test_names="${test_names} ${test_name}"

-    if echo "$test_name"|grep -q _lwip; then
+    if echo "$test_name" | grep -q _lwip; then
         lwip_test_names="${lwip_test_names} ${test_name}"
     fi

@@ -219,13 +224,11 @@
 ping_lwip_clients
 retval=$?

-
 # Wait until all OpenVPN clients have exited
 (wait_for_results)

 # Check test results
-for SUF in $TEST_RUN_LIST
-do
+for SUF in $TEST_RUN_LIST; do
     eval test_name=\"\$TEST_NAME_$SUF\"
     eval should_pass=\"\$SHOULD_PASS_$SUF\"

diff --git a/tests/t_server_null_server.sh b/tests/t_server_null_server.sh
index 65b7d56..0297740 100755
--- a/tests/t_server_null_server.sh
+++ b/tests/t_server_null_server.sh
@@ -1,6 +1,7 @@
 #!/bin/sh

-launch_server() {
+launch_server()
+{
     server_name=$1
     server_exec=$2
     server_conf=$3
@@ -13,10 +14,10 @@

     # Try to launch the server
     $RUN_SUDO "${server_exec}" \
-               $server_conf \
-               --status "${status}" 1 \
-               --writepid "${pid}" \
-               --explicit-exit-notify 3 > "$log" 2>&1 &
+        $server_conf \
+        --status "${status}" 1 \
+        --writepid "${pid}" \
+        --explicit-exit-notify 3 >"$log" 2>&1 &

     sleep 1

@@ -40,8 +41,7 @@
 retval=0

 # Launch test servers
-for SUF in $TEST_SERVER_LIST
-do
+for SUF in $TEST_SERVER_LIST; do
     eval server_name=\"\$SERVER_NAME_$SUF\"
     eval server_exec=\"\$SERVER_EXEC_$SUF\"
     eval server_conf=\"\$SERVER_CONF_$SUF\"
@@ -53,8 +53,7 @@
 # the test run.
 #
 export server_pid_files=""
-for SUF in $TEST_SERVER_LIST
-do
+for SUF in $TEST_SERVER_LIST; do
     eval server_name=\"\$SERVER_NAME_$SUF\"
     server_pid_files="${server_pid_files} ./${server_name}.pid"
 done
@@ -65,12 +64,11 @@
 count=0
 maxcount=4
 while [ $count -le $maxcount ]; do
-    if ls t_server_null_client.sh*.pid > /dev/null 2>&1
-    then
+    if ls t_server_null_client.sh*.pid >/dev/null 2>&1; then
         count=0
         sleep 1
     else
-	count=$(( count + 1))
+        count=$((count + 1))
         sleep 1
     fi
 done
@@ -81,11 +79,10 @@
 # server process does not exit in 15 seconds assume it never will, move on and
 # hope for the best.
 echo "Waiting for servers to exit"
-for PID_FILE in $server_pid_files
-do
+for PID_FILE in $server_pid_files; do
     SERVER_PID=$(cat "${PID_FILE}")

-    if [ -z "$SERVER_PID" ] ; then
+    if [ -z "$SERVER_PID" ]; then
         echo "WARNING: could not kill server ${PID_FILE}!"
         continue
     fi
@@ -95,17 +92,16 @@

     count=0
     maxcount=75
-    while [ $count -le $maxcount ]
-    do
-        $RUN_SUDO kill -0 "${SERVER_PID}" 2> /dev/null || break
-        count=$(( count + 1))
+    while [ $count -le $maxcount ]; do
+        $RUN_SUDO kill -0 "${SERVER_PID}" 2>/dev/null || break
+        count=$((count + 1))
         sleep 0.2
     done

     # If server is still up send a SIGKILL
     if [ $count -ge $maxcount ]; then
         $RUN_SUDO $KILL_EXEC -9 "${SERVER_PID}"
-        SERVER_NAME=$(basename $PID_FILE|cut -d . -f 1)
+        SERVER_NAME=$(basename $PID_FILE | cut -d . -f 1)
         echo "ERROR: had to send SIGKILL to server ${SERVER_NAME} with pid ${SERVER_PID}!"
         echo "Tail of server log:"
         tail -n 20 "${t_server_null_logdir}/${SERVER_NAME}.log"
diff --git a/tests/t_server_null_stress.sh b/tests/t_server_null_stress.sh
index 0bb9452..2fc9fde 100755
--- a/tests/t_server_null_stress.sh
+++ b/tests/t_server_null_stress.sh
@@ -7,8 +7,7 @@
 . ./t_server_null_default.rc

 export pid_files=""
-for SUF in $TEST_SERVER_LIST
-do
+for SUF in $TEST_SERVER_LIST; do
     eval server_name=\"\$SERVER_NAME_$SUF\"
     pid_files="${pid_files} ./${server_name}.pid"
 done
@@ -18,16 +17,16 @@

 count=0
 while [ $count -lt $ITERATIONS ]; do
-    count=$(( count + 1 ))
-    make check TESTS=t_server_null.sh SUBDIRS= > /dev/null 2>&1
+    count=$((count + 1))
+    make check TESTS=t_server_null.sh SUBDIRS= >/dev/null 2>&1
     retval=$?

-    echo "Iteration ${count}: return value ${retval}" >> "${LOG_BASEDIR}/make-check.log"
+    echo "Iteration ${count}: return value ${retval}" >>"${LOG_BASEDIR}/make-check.log"
     if [ $retval -ne 0 ]; then
-	DIR="${LOG_BASEDIR}/make-check-${count}"
+        DIR="${LOG_BASEDIR}/make-check-${count}"
         mkdir -p "${DIR}"
         cp t_server_null*.log "${DIR}/"
         cp test-suite.log "${DIR}/"
-        ps aux|grep openvpn|grep -vE '(suppress|grep)' > "${DIR}/psaux"
+        ps aux | grep openvpn | grep -vE '(suppress|grep)' >"${DIR}/psaux"
     fi
 done
diff --git a/tests/update_t_client_ips.sh b/tests/update_t_client_ips.sh
index 96e3826..777a286 100755
--- a/tests/update_t_client_ips.sh
+++ b/tests/update_t_client_ips.sh
@@ -5,12 +5,12 @@

 RC="$TOP_BUILDDIR/t_client_ips.rc"

-grep EXPECT_IFCONFIG4_$TESTNUM= $RC > /dev/null 2>&1
+grep EXPECT_IFCONFIG4_$TESTNUM= $RC >/dev/null 2>&1
 if [ $? -ne 0 ]; then
-    echo "EXPECT_IFCONFIG4_$TESTNUM=$ifconfig_local" >> $RC
+    echo "EXPECT_IFCONFIG4_$TESTNUM=$ifconfig_local" >>$RC
 fi

-grep EXPECT_IFCONFIG6_$TESTNUM= $RC > /dev/null 2>&1
+grep EXPECT_IFCONFIG6_$TESTNUM= $RC >/dev/null 2>&1
 if [ $? -ne 0 ]; then
-    echo "EXPECT_IFCONFIG6_$TESTNUM=$ifconfig_ipv6_local" >> $RC
+    echo "EXPECT_IFCONFIG6_$TESTNUM=$ifconfig_ipv6_local" >>$RC
 fi

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1793?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f
Gerrit-Change-Number: 1793
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <frank@lichtenheld.com>
Gerrit-Reviewer: plaisthos <arne-openvpn@rfc2549.org>
Gerrit-CC: openvpn-devel <openvpn-devel@lists.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@rfc2549.org>
Gerrit-Attention: flichtenheld <frank@lichtenheld.com>

[-- Attachment #1.2: Type: text/html, Size: 121341 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Openvpn-devel] [L] Change in openvpn[master]: Reformat all shell-scripts with shfmt
       [not found] <gerrit.1784305303000.I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f@gerrit.openvpn.net>
                   ` (2 preceding siblings ...)
  2026-07-22 13:11 ` flichtenheld (Code Review) via Openvpn-devel
@ 2026-08-18  6:31 ` razvanc (Code Review) via Openvpn-devel
  2026-08-19 11:42 ` flichtenheld (Code Review) via Openvpn-devel
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: razvanc (Code Review) via Openvpn-devel @ 2026-08-18  6:31 UTC (permalink / raw)
  To: flichtenheld; +Cc: razvanc (Code Review), openvpn-devel, plaisthos


[-- Attachment #1.1: Type: text/plain, Size: 1582 bytes --]

Attention is currently required from: flichtenheld, plaisthos.

razvanc has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1793?usp=email )

Change subject: Reformat all shell-scripts with shfmt
......................................................................


Patch Set 2:

(1 comment)

File dev-tools/gen-release-tarballs.sh:

http://gerrit.openvpn.net/c/openvpn/+/1793/comment/5c92132b_f4bb5934?usp=email :
PS2, Line 72:     res="$(find . -maxdepth 1 -type f -name \"$wildcard\" | head -n1 | cut -d/ -f2-)"
This doesn't have the same meaning as before. Within backticks slashes get stripped, but within `$()` they don't, so now `\"` will match a quote.

You can test with `"openvpn-2.7.0.tar.gz"` (quotes included).



--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1793?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f
Gerrit-Change-Number: 1793
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <frank@lichtenheld.com>
Gerrit-Reviewer: plaisthos <arne-openvpn@rfc2549.org>
Gerrit-CC: openvpn-devel <openvpn-devel@lists.sourceforge.net>
Gerrit-CC: razvanc <razvanc@mailbox.org>
Gerrit-Attention: plaisthos <arne-openvpn@rfc2549.org>
Gerrit-Attention: flichtenheld <frank@lichtenheld.com>
Gerrit-Comment-Date: Tue, 18 Aug 2026 06:31:43 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No

[-- Attachment #1.2: Type: text/html, Size: 2823 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Openvpn-devel] [L] Change in openvpn[master]: Reformat all shell-scripts with shfmt
       [not found] <gerrit.1784305303000.I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f@gerrit.openvpn.net>
                   ` (3 preceding siblings ...)
  2026-08-18  6:31 ` razvanc (Code Review) via Openvpn-devel
@ 2026-08-19 11:42 ` flichtenheld (Code Review) via Openvpn-devel
  2026-08-19 11:44 ` flichtenheld (Code Review) via Openvpn-devel
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: flichtenheld (Code Review) via Openvpn-devel @ 2026-08-19 11:42 UTC (permalink / raw)
  To: plaisthos; +Cc: flichtenheld (Code Review), openvpn-devel


[-- Attachment #1.1: Type: text/plain, Size: 58207 bytes --]

Attention is currently required from: flichtenheld, plaisthos.

Hello plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1793?usp=email

to look at the new patch set (#3).


Change subject: Reformat all shell-scripts with shfmt
......................................................................

Reformat all shell-scripts with shfmt

According to ./dev-tools/reformat-shell.sh.

Change-Id: I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
---
M dev-tools/gen-release-tarballs.sh
M dev-tools/git-pre-commit-format.sh
M dev-tools/run-cppcheck.sh
M dev-tools/update-copyright.sh
M tests/lwip_client_up.sh
M tests/null_client_up.sh
M tests/t_client.sh.in
M tests/t_cltsrv.sh
M tests/t_lpback.sh
M tests/t_net.sh
M tests/t_server_null.sh
M tests/t_server_null_client.sh
M tests/t_server_null_server.sh
M tests/t_server_null_stress.sh
M tests/update_t_client_ips.sh
15 files changed, 410 insertions(+), 410 deletions(-)


  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/93/1793/3

diff --git a/dev-tools/gen-release-tarballs.sh b/dev-tools/gen-release-tarballs.sh
index 83bdc9e..559125d 100755
--- a/dev-tools/gen-release-tarballs.sh
+++ b/dev-tools/gen-release-tarballs.sh
@@ -21,7 +21,7 @@
 if [ $# -ne 4 ]; then
     echo "Usage: $0 <remote-name> <tag-name> <sign-key> <dest-dir>"
     echo ""
-    echo "   remote-name  -- valid remotes: `git remote | tr \\\n ' '`"
+    echo "   remote-name  -- valid remotes: $(git remote | tr \\n ' ')"
     echo "   tag-name     -- An existing release tag"
     echo "   sign-key     -- PGP key used to sign all files"
     echo "   dest-dir     -- Where to put the complete set of release tarballs"
@@ -48,7 +48,7 @@
 fi

 # Extract the git URL
-giturl="`git remote get-url $arg_remote_name 2>/dev/null`"
+giturl="$(git remote get-url $arg_remote_name 2>/dev/null)"
 if [ $? -ne 0 ]; then
     echo "** ERROR ** Invalid git remote name: $arg_remote_name"
     exit 2
@@ -58,10 +58,9 @@
 echo "test" | gpg -a --clearsign -u "$arg_sign_key" 2>/dev/null 1>/dev/null
 if [ $? -ne 0 ]; then
     echo "** ERROR ** Failed when testing the PGP signing.  Wrong signing key?"
-    exit 2;
+    exit 2
 fi

-
 #
 # Helper functions
 #
@@ -87,7 +86,7 @@
     local fileext="$1"
     local dest="$2"

-    file="`get_filename openvpn-*.*.*.$fileext`"
+    file="$(get_filename openvpn-*.*.*.$fileext)"
     if [ -z "$file" ]; then
         echo "** ERROR Failed to find source file"
         exit 5
@@ -96,7 +95,7 @@
     cp "$file" "$dest"
     if [ $? -ne 0 ]; then
         echo "** ERROR ** Failed to copy $file to $destdir"
-        exit 3;
+        exit 3
     fi
 }

@@ -105,7 +104,7 @@
     local signkey="$1"
     local srchfile="$2"
     local signtype="$3"
-    local file="`get_filename $srchfile`"
+    local file="$(get_filename $srchfile)"

     echo "-- Signing $file ..."
     case "$signtype" in
@@ -126,16 +125,16 @@

         *)
             echo "** ERROR **  Unknown signing type \"$signtype\"."
-            exit 4;
+            exit 4
+            ;;
     esac

     if [ $res -ne 0 ]; then
         echo "** ERROR **  Failed to sign the file $PWD/$file"
-        exit 4;
+        exit 4
     fi
 }

-
 #
 # Preparations
 #
@@ -146,7 +145,7 @@
     /*) # Absolute path
         destdir="$arg_dest_dir/$arg_tag_name"
         ;;
-    *)  # Make absolute path from relative path
+    *) # Make absolute path from relative path
         destdir="$PWD/$arg_dest_dir/$arg_tag_name"
         ;;
 esac
@@ -168,61 +167,61 @@
 #

 # Clone the remote repository
-workdir="`mktemp -d -p /var/tmp openvpn-build-release-XXXXXX`"
+workdir="$(mktemp -d -p /var/tmp openvpn-build-release-XXXXXX)"
 cd $workdir
 echo "-- Working directory: $workdir"
 echo "-- git clone $giturl"
-git clone $giturl openvpn-gen-tarball 2> "$workdir/git-clone.log" 1>&2
+git clone $giturl openvpn-gen-tarball 2>"$workdir/git-clone.log" 1>&2
 if [ $? -ne 0 ]; then
     echo "** ERROR **  git clone failed.  See $workdir/git-clone.log for details"
-    exit 3;
+    exit 3
 fi
 cd openvpn-gen-tarball

 # Check out the proper release tag
 echo "-- Checking out tag $arg_tag_name ... "
-git checkout -b mkrelease "$arg_tag_name" 2> "$workdir/git-checkout-tag.log" 1>&2
+git checkout -b mkrelease "$arg_tag_name" 2>"$workdir/git-checkout-tag.log" 1>&2
 if [ $? -ne 0 ]; then
     echo "** ERROR **  git checkout failed.  See $workdir/git-checkout-tag.log for details"
-    exit 3;
+    exit 3
 fi

 # Prepare the source tree
 echo "-- Running autoreconf + a simple configure ... "
-(autoreconf -vi && ./configure) 2> "$workdir/autotools-prep.log" 1>&2
+(autoreconf -vi && ./configure) 2>"$workdir/autotools-prep.log" 1>&2
 if [ $? -ne 0 ]; then
     echo "** ERROR **  Failed running autotools.  See $workdir/autotools-prep.log for details"
-    exit 3;
+    exit 3
 fi

 # Generate the tar/zip files
 echo "-- Running make distcheck (generates .tar.gz) ... "
-(make distcheck) 2> "$workdir/make-distcheck.log" 1>&2
+(make distcheck) 2>"$workdir/make-distcheck.log" 1>&2
 if [ $? -ne 0 ]; then
     echo "** ERROR **  make distcheck failed.  See $workdir/make-distcheck.log for details"
-    exit 3;
+    exit 3
 fi
 copy_files tar.gz "$destdir"

 echo "-- Running make dist-xz (generates .tar.xz) ... "
-(make dist-xz) 2> "$workdir/make-dist-xz.log" 1>&2
+(make dist-xz) 2>"$workdir/make-dist-xz.log" 1>&2
 if [ $? -ne 0 ]; then
     echo "** ERROR **  make dist-xz failed.  See $workdir/make-dist-xz.log for details"
-    exit 3;
+    exit 3
 fi
 copy_files tar.xz "$destdir"

 echo "-- Running make dist-zip (generates .zip) ... "
-(make dist-zip) 2> "$workdir/make-dist-zip.log" 1>&2
+(make dist-zip) 2>"$workdir/make-dist-zip.log" 1>&2
 if [ $? -ne 0 ]; then
     echo "** ERROR **  make dist-zip failed.  See $workdir/make-dist-zip.log for details"
-    exit 3;
+    exit 3
 fi
 copy_files zip "$destdir"

 # Generate SHA256 checksums
 cd "$destdir"
-sha256sum openvpn-*.tar.{gz,xz} openvpn-*.zip > "openvpn-$arg_tag_name.sha256sum"
+sha256sum openvpn-*.tar.{gz,xz} openvpn-*.zip >"openvpn-$arg_tag_name.sha256sum"

 # Sign all the files
 echo "-- Signing files ... "
diff --git a/dev-tools/git-pre-commit-format.sh b/dev-tools/git-pre-commit-format.sh
index 9b2ecaf..3507289 100755
--- a/dev-tools/git-pre-commit-format.sh
+++ b/dev-tools/git-pre-commit-format.sh
@@ -26,7 +26,6 @@
 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-
 # git pre-commit hook that runs a stylecheck.
 # Features:
 #  - abort commit when commit does not comply with the style guidelines
@@ -43,12 +42,11 @@
 # exit on error
 set -e

-
 # If called so, install this script as pre-commit hook
-if [ "$1" = "install" ] ; then
+if [ "$1" = "install" ]; then
     TARGET="$(git rev-parse --git-path hooks)/pre-commit"

-    if [ -e "$TARGET" ] ; then
+    if [ -e "$TARGET" ]; then
         printf "$TARGET file exists. Won't overwrite.\n"
         printf "Aborting installation.\n"
         exit 1
@@ -62,18 +60,19 @@
 fi

 # check whether the given file matches any of the set extensions
-matches_extension() {
+matches_extension()
+{
     local filename="$(basename -- "$1")"
     local extension=".${filename##*.}"
     local ext

-    for ext in .c .h ; do [ "$ext" = "$extension" ] && return 0; done
+    for ext in .c .h; do [ "$ext" = "$extension" ] && return 0; done

     return 1
 }

 # necessary check for initial commit
-if git rev-parse --verify HEAD >/dev/null 2>&1 ; then
+if git rev-parse --verify HEAD >/dev/null 2>&1; then
     against=HEAD
 else
     # Initial commit: diff against an empty tree object
@@ -88,8 +87,8 @@

     # Allow to use in parallel with pre-commit
     if [ $(basename "$0") = "pre-commit.legacy" ]; then
-       echo "Skipping clang-format check in favor of pre-commit"
-       exit 0
+        echo "Skipping clang-format check in favor of pre-commit"
+        exit 0
     fi
 else
     TOOL=uncrustify
@@ -98,7 +97,7 @@
     TOOL_CMD="$TOOL_BIN -q -l C -c $UNCRUST_CONFIG"

     # make sure the config file is correctly set
-    if [ ! -f "$UNCRUST_CONFIG" ] ; then
+    if [ ! -f "$UNCRUST_CONFIG" ]; then
         printf "Error: uncrustify config file not found.\n"
         printf "Expected to find it at $UNCRUST_CONFIG.\n"
         printf "Aborting commit.\n"
@@ -106,7 +105,7 @@
     fi
 fi

-if [ -z "$TOOL_BIN" ] ; then
+if [ -z "$TOOL_BIN" ]; then
     printf "Error: $TOOL executable not found.\n"
     printf "Is it installed and in your \$PATH?\n"
     printf "Aborting commit.\n"
@@ -120,44 +119,43 @@
 # create one patch containing all changes to the files
 # sed to remove quotes around the filename, if inserted by the system
 # (done sometimes, if the filename contains special characters, like the quote itself)
-git diff-index --cached --diff-filter=ACMR --name-only $against -- | \
-sed -e 's/^"\(.*\)"$/\1/' | \
-while read file
-do
-    # ignore file if we do check for file extensions and the file
-    # does not match the extensions .c or .h
-    if ! matches_extension "$file"; then
-        continue;
-    fi
+git diff-index --cached --diff-filter=ACMR --name-only $against -- |
+    sed -e 's/^"\(.*\)"$/\1/' |
+    while read file; do
+        # ignore file if we do check for file extensions and the file
+        # does not match the extensions .c or .h
+        if ! matches_extension "$file"; then
+            continue
+        fi

-    # escape special characters in the target filename:
-    # phase 1 (characters escaped in the output diff):
-    #     - '\': backslash needs to be escaped in the output diff
-    #     - '"': quote needs to be escaped in the output diff if present inside
-    #            of the filename, as it used to bracket the entire filename part
-    # phase 2 (characters escaped in the match replacement):
-    #     - '\': backslash needs to be escaped again for sed itself
-    #            (i.e. double escaping after phase 1)
-    #     - '&': would expand to matched string
-    #     - '|': used as sed split char instead of '/'
-    # printf %s particularly important if the filename contains the % character
-    file_escaped_target=$(printf "%s" "$file" | sed -e 's/[\"]/\\&/g' -e 's/[\&|]/\\&/g')
+        # escape special characters in the target filename:
+        # phase 1 (characters escaped in the output diff):
+        #     - '\': backslash needs to be escaped in the output diff
+        #     - '"': quote needs to be escaped in the output diff if present inside
+        #            of the filename, as it used to bracket the entire filename part
+        # phase 2 (characters escaped in the match replacement):
+        #     - '\': backslash needs to be escaped again for sed itself
+        #            (i.e. double escaping after phase 1)
+        #     - '&': would expand to matched string
+        #     - '|': used as sed split char instead of '/'
+        # printf %s particularly important if the filename contains the % character
+        file_escaped_target=$(printf "%s" "$file" | sed -e 's/[\"]/\\&/g' -e 's/[\&|]/\\&/g')

-    # uncrustify our sourcefile, create a patch with diff and append it to our $patch
-    # The sed call is necessary to transform the patch from
-    #    --- - timestamp
-    #    +++ $tmpout timestamp
-    # to both lines working on the same file and having a a/ and b/ prefix.
-    # Else it can not be applied with 'git apply'.
-    git show ":$file" | $TOOL_CMD > "$tmpout"
-    git show ":$file" | diff -u -- - "$tmpout" | \
-        sed -e "1s|--- -|--- \"b/$file_escaped_target\"|" -e "2s|+++ $tmpout|+++ \"a/$file_escaped_target\"|" >> "$patch"
-done
+        # uncrustify our sourcefile, create a patch with diff and append it to our $patch
+        # The sed call is necessary to transform the patch from
+        #    --- - timestamp
+        #    +++ $tmpout timestamp
+        # to both lines working on the same file and having a a/ and b/ prefix.
+        # Else it can not be applied with 'git apply'.
+        git show ":$file" | $TOOL_CMD >"$tmpout"
+        git show ":$file" | diff -u -- - "$tmpout" |
+            sed -e "1s|--- -|--- \"b/$file_escaped_target\"|" -e "2s|+++ $tmpout|+++ \"a/$file_escaped_target\"|" >>"$patch"
+    done

 rm -f "$tmpout"

 # if no patch has been generated all is ok, clean up the file stub and exit
-if [ ! -s "$patch" ] ; then
+if [ ! -s "$patch" ]; then
     rm -f "$patch"
     exit 0
 fi
@@ -165,7 +163,7 @@
 # a patch has been created, notify the user and exit
 printf "Formatting of some code does not follow the project guidelines.\n"

-if [ $(wc -l < $patch) -gt 80 ] ; then
+if [ $(wc -l <$patch) -gt 80 ]; then
     printf "The file $patch contains the necessary fixes.\n"
 else
     printf "Here's the patch that fixes the formatting:\n\n"
diff --git a/dev-tools/run-cppcheck.sh b/dev-tools/run-cppcheck.sh
index 40db33e..a7aa3c4 100755
--- a/dev-tools/run-cppcheck.sh
+++ b/dev-tools/run-cppcheck.sh
@@ -20,24 +20,23 @@
  --check-level=exhaustive --max-configs=10 \
  --error-exitcode=1"

-
 set -x

 mkdir -p "$CPPCHECK_DIR"
 cd "${SOURCE_DIR}"
 cppcheck $COMMON_ARGS $INCLUDE_FLAGS \
-         --platform=unix64 \
-         --library=posix.cfg --library=bsd.cfg --library=gnu.cfg \
-         -U_WIN32 \
-         src/openvpn/ src/compat/ src/plugins/ sample/ \
-         tests/unit_tests/example_test/ tests/unit_tests/openvpn/ \
-         tests/unit_tests/plugins/
+    --platform=unix64 \
+    --library=posix.cfg --library=bsd.cfg --library=gnu.cfg \
+    -U_WIN32 \
+    src/openvpn/ src/compat/ src/plugins/ sample/ \
+    tests/unit_tests/example_test/ tests/unit_tests/openvpn/ \
+    tests/unit_tests/plugins/
 cppcheck $COMMON_ARGS \
-         --platform=win64 \
-         --library=windows.cfg \
-         -D_WIN32 \
-         -UTARGET_LINUX -UTARGET_FREEBSD -UTARGET_OPENBSD -UTARGET_NETBSD \
-         -UTARGET_DARWIN -UTARGET_ANDROID -UTARGET_SOLARIS -UTARGET_DRAGONFLY \
-         -UTARGET_AIX \
-         src/openvpn* src/compat/ \
-         tests/unit_tests/example_test/ tests/unit_tests/openvpn*
+    --platform=win64 \
+    --library=windows.cfg \
+    -D_WIN32 \
+    -UTARGET_LINUX -UTARGET_FREEBSD -UTARGET_OPENBSD -UTARGET_NETBSD \
+    -UTARGET_DARWIN -UTARGET_ANDROID -UTARGET_SOLARIS -UTARGET_DRAGONFLY \
+    -UTARGET_AIX \
+    src/openvpn* src/compat/ \
+    tests/unit_tests/example_test/ tests/unit_tests/openvpn*
diff --git a/dev-tools/update-copyright.sh b/dev-tools/update-copyright.sh
index 96546dd..7ca6002 100755
--- a/dev-tools/update-copyright.sh
+++ b/dev-tools/update-copyright.sh
@@ -34,8 +34,7 @@
 COPY_YEAR="$1"

 cd "$(git rev-parse --show-toplevel)"
-for file in $(git ls-files | grep -v vendor/);
-do
+for file in $(git ls-files | grep -v vendor/); do
     echo -n "Updating $file ..."
     # The first sed operation covers 20xx-20yy copyright lines,
     # The second sed operation changes 20xx -> 20xx-20yy
diff --git a/tests/lwip_client_up.sh b/tests/lwip_client_up.sh
index a6b4d24..b1941a4 100755
--- a/tests/lwip_client_up.sh
+++ b/tests/lwip_client_up.sh
@@ -2,16 +2,17 @@
 #
 # Determine the OpenVPN PID from its pid file. This works reliably even when
 # the OpenVPN process is backgrounded for parallel tests.
-MY_PPID=`cat $pid`
+MY_PPID=$(cat $pid)

 # Add this client's VPN IP and PID to a file. This enables
 # t_server_null_client.sh to kill this OpenVPN client after fping tests have
 # finished.
-echo "$ifconfig_local,$MY_PPID" >> ./$test_name.lwip
+echo "$ifconfig_local,$MY_PPID" >>./$test_name.lwip

 # Wait long enough to allow fping tests to finish. Also ensure that this
 # OpenVPN client is killed even if t_server_null_client.sh failed to do it.
-(sleep 15
-echo "ERROR: t_server_null_client.sh failed to kill OpenVPN client with PID $MY_PPID in test $test_name. Killing it in lwip_client_up.sh."
-kill -15 $MY_PPID
+(
+    sleep 15
+    echo "ERROR: t_server_null_client.sh failed to kill OpenVPN client with PID $MY_PPID in test $test_name. Killing it in lwip_client_up.sh."
+    kill -15 $MY_PPID
 ) &
diff --git a/tests/null_client_up.sh b/tests/null_client_up.sh
index d4df0c6..be339ee 100755
--- a/tests/null_client_up.sh
+++ b/tests/null_client_up.sh
@@ -4,8 +4,11 @@

 # Determine the OpenVPN PID from its pid file. This works reliably even when
 # the OpenVPN process is backgrounded for parallel tests.
-MY_PPID=`cat $pid`
+MY_PPID=$(cat $pid)
 
 # Allow OpenVPN to finish initializing while waiting in the background and then
 # killing the process gracefully.
-(sleep 5 ; kill -15 $MY_PPID) &
+(
+    sleep 5
+    kill -15 $MY_PPID
+) &
diff --git a/tests/t_client.sh.in b/tests/t_client.sh.in
index 2f37845..305441be 100755
--- a/tests/t_client.sh.in
+++ b/tests/t_client.sh.in
@@ -19,9 +19,9 @@
 srcdir="${srcdir:-.}"
 top_builddir="${top_builddir:-..}"
 openvpn="${openvpn:-${top_builddir}/src/openvpn/openvpn}"
-if [ -r "${top_builddir}"/t_client.rc ] ; then
+if [ -r "${top_builddir}"/t_client.rc ]; then
     . "${top_builddir}"/t_client.rc
-elif [ -r "${srcdir}"/t_client.rc ] ; then
+elif [ -r "${srcdir}"/t_client.rc ]; then
     . "${srcdir}"/t_client.rc
 else
     echo "$0: cannot find 't_client.rc' in build dir ('${top_builddir}')" >&2
@@ -32,37 +32,35 @@
 # Check for external dependencies
 FPING="fping"
 FPING6="fping6"
-which fping > /dev/null
+which fping >/dev/null
 if [ $? -ne 0 ]; then
     echo "$0: fping is not available in \$PATH" >&2
     exit "${TCLIENT_SKIP_RC}"
 fi
-which fping6 > /dev/null
+which fping6 >/dev/null
 if [ $? -ne 0 ]; then
     echo "$0: fping6 is not available in \$PATH, assuming fping 4.0 or later" >&2
     FPING="fping -4"
     FPING6="fping -6"
 fi

-KILL_EXEC=`which kill`
+KILL_EXEC=$(which kill)
 if [ $? -ne 0 ]; then
     echo "$0: kill not found in \$PATH" >&2
     exit "${TCLIENT_SKIP_RC}"
 fi

-if [ ! -x "${openvpn}" ]
-then
+if [ ! -x "${openvpn}" ]; then
     echo "no (executable) openvpn binary in current build tree. FAIL." >&2
     exit 1
 fi

-if [ ! -w . ]
-then
+if [ ! -w . ]; then
     echo "current directory is not writable (required for logging). FAIL." >&2
     exit 1
 fi

-if [ -z "$TEST_RUN_LIST" ] ; then
+if [ -z "$TEST_RUN_LIST" ]; then
     echo "TEST_RUN_LIST empty, no tests defined.  SKIP test." >&2
     exit "${TCLIENT_SKIP_RC}"
 fi
@@ -72,16 +70,14 @@

 # make sure we have permissions to run ifconfig/route from OpenVPN
 # can't use "id -u" here - doesn't work on Solaris
-ID=`id`
-if expr "$ID" : "uid=0" >/dev/null
-then :
+ID=$(id)
+if expr "$ID" : "uid=0" >/dev/null; then
+    :
 else
-    if [ "${PREFER_KSU}" -eq 1 ];
-    then
+    if [ "${PREFER_KSU}" -eq 1 ]; then
         # Check if we have a valid kerberos ticket
         klist -l 1>/dev/null 2>/dev/null
-        if [ $? -ne 0 ];
-        then
+        if [ $? -ne 0 ]; then
             # No kerberos ticket found, skip ksu and fallback to RUN_SUDO
             PREFER_KSU=0
             echo "$0: No Kerberos ticket available.  Will not use ksu."
@@ -90,8 +86,7 @@
         fi
     fi

-    if [ -z "$RUN_SUDO" ]
-    then
+    if [ -z "$RUN_SUDO" ]; then
         echo "$0: this test must run be as root, or RUN_SUDO=... " >&2
         echo "      must be set correctly in 't_client.rc'. SKIP." >&2
         exit "${TCLIENT_SKIP_RC}"
@@ -99,20 +94,19 @@
         # We have to use sudo. Make sure that we (hopefully) do not have
         # to ask the users password during the test. This is done to
         # prevent timing issues, e.g. when the waits for openvpn to start
-	if $RUN_SUDO $KILL_EXEC -0 $$
-	then
-	    echo "$0: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
-	else
-	    echo "$0: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
-	    exit "${TCLIENT_SKIP_RC}"
-	fi
+        if $RUN_SUDO $KILL_EXEC -0 $$; then
+            echo "$0: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
+        else
+            echo "$0: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
+            exit "${TCLIENT_SKIP_RC}"
+        fi
     fi
 fi

-LOGDIR=t_client-`hostname`-`date +%Y%m%d-%H%M%S`
+LOGDIR=t_client-$(hostname)-$(date +%Y%m%d-%H%M%S)
 LOGDIR_ABS="$PWD/$LOGDIR"
-if mkdir $LOGDIR
-then :
+if mkdir $LOGDIR; then
+    :
 else
     echo "can't create log directory '$LOGDIR'. FAIL." >&2
     exit 1
@@ -132,21 +126,28 @@
 output_start()
 {
     case $V in
-	0) outbuf="" ;;			# no per-test output at all
-	1) printf "$@\n"			# compact, details only on failure
-           outbuf="\n" ;;
-	*) printf "\n$@\n" ;;		# print all, with a bit formatting
+        0) outbuf="" ;; # no per-test output at all
+        1)
+            printf "$@\n" # compact, details only on failure
+            outbuf="\n"
+            ;;
+        *) printf "\n$@\n" ;; # print all, with a bit formatting
     esac
 }

 output()
 {
-    END_NL="\n"; if [ "X$1" = "X-n" ] ; then END_NL="" ; shift ; fi
+    END_NL="\n"
+    if [ "X$1" = "X-n" ]; then
+        END_NL=""
+        shift
+    fi
     case $V in
-	0) ;;				# no per-test output at all
-	1) outbuf="$outbuf$@${END_NL}"	# print details only on failure
-           ;;
-	*) printf "$@${END_NL}" ;;	# print everything
+        0) ;; # no per-test output at all
+        1)
+            outbuf="$outbuf$@${END_NL}" # print details only on failure
+            ;;
+        *) printf "$@${END_NL}" ;; # print everything
     esac
 }

@@ -154,62 +155,61 @@
 fail()
 {
     output "FAIL: $@\n"
-    fail_count=$(( $fail_count + 1 ))
+    fail_count=$(($fail_count + 1))
 }

 # print "all interface IP addresses" + "all routes"
 # this is higly system dependent...
 get_ifconfig_route()
 {
-    UNAME=`uname -s`
+    UNAME=$(uname -s)
     case $UNAME in
-	Linux)
+        Linux)
             # linux / iproute2? (-> if configure got a path)
-            if [ -n "@IPROUTE@" ]
-            then
+            if [ -n "@IPROUTE@" ]; then
                 echo "-- linux iproute2 --"
-                @IPROUTE@ addr show     | grep -v valid_lft
+                @IPROUTE@ addr show | grep -v valid_lft
                 @IPROUTE@ route show
                 @IPROUTE@ -o -6 route show | grep -v ' cache' | sed -E -e 's/ expires [0-9]*sec//' -e 's/ (mtu|hoplimit|cwnd|ssthresh) [0-9]+//g' -e 's/ (rtt|rttvar) [0-9]+ms//g'
             else
-	        echo "-- linux / ifconfig --"
-	        LANG=C @IFCONFIG@ -a |egrep  "( addr:|encap:)"
-	        LANG=C @NETSTAT@ -rn -4 -6
+                echo "-- linux / ifconfig --"
+                LANG=C @IFCONFIG@ -a | egrep "( addr:|encap:)"
+                LANG=C @NETSTAT@ -rn -4 -6
             fi
             ;;
-	FreeBSD|NetBSD|Darwin)
-	   echo "-- FreeBSD/NetBSD/Darwin [MacOS X] --"
-	   @IFCONFIG@ -a | egrep "(flags=|inet)"
-	   @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
-	   ;;
-	OpenBSD)
-	   echo "-- OpenBSD --"
-	   @IFCONFIG@ -a | egrep "(flags=|inet)" | \
-		sed -e 's/pltime [0-9]*//' -e 's/vltime [0-9]*//'
-	   @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
-	   ;;
-	SunOS)
-	   echo "-- Solaris --"
-	   @IFCONFIG@ -a | egrep "(flags=|inet)"
-	   @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
-	   ;;
-	AIX)
-	   echo "-- AIX --"
-	   @IFCONFIG@ -a | egrep "(flags=|inet)"
-	   @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
-	   ;;
+        FreeBSD | NetBSD | Darwin)
+            echo "-- FreeBSD/NetBSD/Darwin [MacOS X] --"
+            @IFCONFIG@ -a | egrep "(flags=|inet)"
+            @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
+            ;;
+        OpenBSD)
+            echo "-- OpenBSD --"
+            @IFCONFIG@ -a | egrep "(flags=|inet)" |
+                sed -e 's/pltime [0-9]*//' -e 's/vltime [0-9]*//'
+            @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
+            ;;
+        SunOS)
+            echo "-- Solaris --"
+            @IFCONFIG@ -a | egrep "(flags=|inet)"
+            @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
+            ;;
+        AIX)
+            echo "-- AIX --"
+            @IFCONFIG@ -a | egrep "(flags=|inet)"
+            @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
+            ;;
         *)
-           echo "get_ifconfig_route(): no idea how to get info on your OS (`uname -s`).  FAIL." >&2
-           exit 20
-           ;;
+            echo "get_ifconfig_route(): no idea how to get info on your OS ($(uname -s)).  FAIL." >&2
+            exit 20
+            ;;
     esac

     # another round of per-platform information gathering, for DNS info
     # for most of the platforms "cat /etc/resolv.conf" is good enough
     # except Linux and MacOS
     case $UNAME in
-	Linux)
-            if [ -x /usr/bin/resolvectl -a -d /run/systemd/system ] ; then
+        Linux)
+            if [ -x /usr/bin/resolvectl -a -d /run/systemd/system ]; then
                 echo "-- linux resolvectl --"
                 resolvectl status
             else
@@ -217,7 +217,7 @@
                 cat /etc/resolv.conf
             fi
             ;;
-	Darwin)
+        Darwin)
             echo "-- MacOS scutil --dns"
             scutil --dns
             ;;
@@ -234,19 +234,19 @@
 #  arg2: IPv4/IPv6 address that must show up in out of "get_ifconfig_route"
 check_ifconfig()
 {
-    proto=$1 ; shift
+    proto=$1
+    shift
     expect_list="$@"

-    if [ -z "$expect_list" ] ; then return ; fi
-    if [ "$expect_list" = "-" ] ; then return ; fi
+    if [ -z "$expect_list" ]; then return; fi
+    if [ "$expect_list" = "-" ]; then return; fi

-    for expect in $expect_list
-    do
-	if get_ifconfig_route | fgrep "$expect" >/dev/null
-	then :
-	else
-	    fail "check_ifconfig(): expected IPv$proto address '$expect' not found in ifconfig output."
-	fi
+    for expect in $expect_list; do
+        if get_ifconfig_route | fgrep "$expect" >/dev/null; then
+            :
+        else
+            fail "check_ifconfig(): expected IPv$proto address '$expect' not found in ifconfig output."
+        fi
     done
 }

@@ -257,47 +257,48 @@
 #  arg3... -> fping arguments (host list)
 run_ping_tests()
 {
-    proto=$1 ; want=$2 ; shift ; shift
+    proto=$1
+    want=$2
+    shift
+    shift
     targetlist="$@"

     # "no targets" is fine
-    if [ -z "$targetlist" ] ; then return ; fi
+    if [ -z "$targetlist" ]; then return; fi

     case $proto in
-	4) cmd="$FPING" ;;
-	6) cmd="$FPING6" ;;
-	*) echo "internal error in run_ping_tests arg 1: '$proto'" >&2
-	   exit 1 ;;
+        4) cmd="$FPING" ;;
+        6) cmd="$FPING6" ;;
+        *)
+            echo "internal error in run_ping_tests arg 1: '$proto'" >&2
+            exit 1
+            ;;
     esac

     case $want in
-	want_ok)   sizes_list="64 1440 3000" ;;
-	want_fail) sizes_list="64" ;;
+        want_ok) sizes_list="64 1440 3000" ;;
+        want_fail) sizes_list="64" ;;
     esac

-    for bytes in $sizes_list
-    do
-	output "run IPv$proto ping tests ($want), $bytes byte packets..."
+    for bytes in $sizes_list; do
+        output "run IPv$proto ping tests ($want), $bytes byte packets..."

-	echo "$cmd -b $bytes -C 20 -p 250 -q $fping_args $targetlist" >>$LOGDIR/$SUF:fping.out
-	$cmd -b $bytes -C 20 -p 250 -q $fping_args $targetlist >>$LOGDIR/$SUF:fping.out 2>&1
+        echo "$cmd -b $bytes -C 20 -p 250 -q $fping_args $targetlist" >>$LOGDIR/$SUF:fping.out
+        $cmd -b $bytes -C 20 -p 250 -q $fping_args $targetlist >>$LOGDIR/$SUF:fping.out 2>&1

-	# while OpenVPN is running, pings must succeed (want='want_ok')
-	# before OpenVPN is up, pings must NOT succeed (want='want_fail')
+        # while OpenVPN is running, pings must succeed (want='want_ok')
+        # before OpenVPN is up, pings must NOT succeed (want='want_fail')

-	rc=$?
-	if [ $rc = 0 ] 				# all ping OK
-	then
-	    if [ $want = "want_fail" ]		# not what we want
-	    then
-		fail "IPv$proto ping test succeeded, but needs to *fail*."
-	    fi
-	else					# ping failed
-	    if [ $want = "want_ok" ]		# not what we wanted
-	    then
-		fail "IPv$proto ping test ($bytes bytes) failed, but should succeed."
-	    fi
-	fi
+        rc=$?
+        if [ $rc = 0 ]; then                 # all ping OK
+            if [ $want = "want_fail" ]; then # not what we want
+                fail "IPv$proto ping test succeeded, but needs to *fail*."
+            fi
+        else                               # ping failed
+            if [ $want = "want_ok" ]; then # not what we wanted
+                fail "IPv$proto ping test ($bytes bytes) failed, but should succeed."
+            fi
+        fi
     done
 }

@@ -308,8 +309,7 @@
 SUMMARY_SKIP=
 SUMMARY_FAIL=

-for SUF in $TEST_RUN_LIST
-do
+for SUF in $TEST_RUN_LIST; do
     # get config variables
     eval test_prep=\"\$PREPARE_$SUF\"
     eval test_check_skip=\"\$CHECK_SKIP_$SUF\"
@@ -336,11 +336,13 @@

     if [ -n "$test_check_skip" ]; then
         output "check whether we need to skip: '$test_check_skip'"
-        if eval $test_check_skip; then :
+        if eval $test_check_skip; then
+            :
         else
             output "skip check failed, SKIP test $SUF."
-	    SUMMARY_SKIP="$SUMMARY_SKIP $SUF"
-	    printf "$outbuf" ; continue
+            SUMMARY_SKIP="$SUMMARY_SKIP $SUF"
+            printf "$outbuf"
+            continue
         fi
     fi

@@ -355,13 +357,14 @@
     output "\nrun pre-openvpn ping tests - targets must not be reachable..."
     run_ping_tests 4 want_fail "$ping4_hosts"
     run_ping_tests 6 want_fail "$ping6_hosts"
-    if [ "$fail_count" = 0 ] ; then
+    if [ "$fail_count" = 0 ]; then
         output "OK.\n"
     else
-	fail "make sure that ping hosts are ONLY reachable via VPN, SKIP test $SUF."
-	SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
-	exit_code=31
-	printf "$outbuf" ; continue
+        fail "make sure that ping hosts are ONLY reachable via VPN, SKIP test $SUF."
+        SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
+        exit_code=31
+        printf "$outbuf"
+        continue
     fi

     pidfile="$LOGDIR_ABS/openvpn-$SUF.pid"
@@ -376,18 +379,17 @@
     # to $ovpn_init_check times.
     ovpn_init_check=30
     ovpn_init_success=0
-    while [ $ovpn_init_check -gt 0 ];
-    do
-       sleep 1  # Wait for OpenVPN to initialize and have had time to write the pid file
-       grep "Initialization Sequence Completed" $LOGDIR/$SUF:openvpn.log >/dev/null
-       if [ $? -eq 0 ]; then
-           ovpn_init_check=0
-           ovpn_init_success=1
-       fi
-       ovpn_init_check=$(( $ovpn_init_check - 1 ))
+    while [ $ovpn_init_check -gt 0 ]; do
+        sleep 1 # Wait for OpenVPN to initialize and have had time to write the pid file
+        grep "Initialization Sequence Completed" $LOGDIR/$SUF:openvpn.log >/dev/null
+        if [ $? -eq 0 ]; then
+            ovpn_init_check=0
+            ovpn_init_success=1
+        fi
+        ovpn_init_check=$(($ovpn_init_check - 1))
     done

-    opid=`cat $pidfile`
+    opid=$(cat $pidfile)
     if [ -n "$opid" ]; then
         output "  OpenVPN running with PID $opid"
     else
@@ -398,16 +400,17 @@
     if [ $ovpn_init_success -ne 1 -o -z "$opid" ]; then
         output "$0:  OpenVPN did not initialize in a reasonable time"
         if [ -n "$opid" ]; then
-           $RUN_SUDO $KILL_EXEC $opid
+            $RUN_SUDO $KILL_EXEC $opid
         fi
         $RUN_SUDO $KILL_EXEC $sudopid
-	output "tail -5 $SUF:openvpn.log"
-	output "`tail -5 $LOGDIR/$SUF:openvpn.log`"
-	fail "skip rest of sub-tests for test run $SUF."
-	trap - 0 1 2 3 15
-	SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
-	exit_code=30
-	printf "$outbuf" ; continue
+        output "tail -5 $SUF:openvpn.log"
+        output "$(tail -5 $LOGDIR/$SUF:openvpn.log)"
+        fail "skip rest of sub-tests for test run $SUF."
+        trap - 0 1 2 3 15
+        SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
+        exit_code=30
+        printf "$outbuf"
+        continue
     fi

     # make sure openvpn client is terminated in case shell exits
@@ -418,17 +421,16 @@
     output "save ifconfig+route"
     get_ifconfig_route >$LOGDIR/$SUF:ifconfig_route.txt

-    if [ "$expect_ifconfig4" = "-" ] ; then
+    if [ "$expect_ifconfig4" = "-" ]; then
         output "skip ifconfig+route check"
     else
-	output -n "compare pre-openvpn ifconfig+route with current values..."
-	if diff $LOGDIR/$SUF:ifconfig_route_pre.txt \
-		$LOGDIR/$SUF:ifconfig_route.txt >/dev/null
-	then
-	    fail "no differences between ifconfig/route before OpenVPN start and now."
-	else
-	    output " OK!\n"
-	fi
+        output -n "compare pre-openvpn ifconfig+route with current values..."
+        if diff $LOGDIR/$SUF:ifconfig_route_pre.txt \
+            $LOGDIR/$SUF:ifconfig_route.txt >/dev/null; then
+            fail "no differences between ifconfig/route before OpenVPN start and now."
+        else
+            output " OK!\n"
+        fi
     fi

     # post init script needed?
@@ -449,8 +451,8 @@
     $RUN_SUDO $KILL_EXEC $opid
     wait $!
     rc=$?
-    if [ $rc != 0 ] ; then
-	fail "OpenVPN return code $rc, expect 0"
+    if [ $rc != 0 ]; then
+        fail "OpenVPN return code $rc, expect 0"
     fi

     output "\nsave post-openvpn ifconfig + route..."
@@ -458,23 +460,22 @@

     output -n "compare pre- and post-openvpn ifconfig + route..."
     if diff $LOGDIR/$SUF:ifconfig_route_pre.txt \
-	    $LOGDIR/$SUF:ifconfig_route_post.txt >$LOGDIR/$SUF:ifconfig_route_diff.txt
-    then
-	output " OK.\n"
+        $LOGDIR/$SUF:ifconfig_route_post.txt >$LOGDIR/$SUF:ifconfig_route_diff.txt; then
+        output " OK.\n"
     else
-	output "\n\n" "`cat $LOGDIR/$SUF:ifconfig_route_diff.txt`" "\n"
-	fail "differences between pre- and post-ifconfig/route."
+        output "\n\n" "$(cat $LOGDIR/$SUF:ifconfig_route_diff.txt)" "\n"
+        fail "differences between pre- and post-ifconfig/route."
     fi
-    if [ "$fail_count" = 0 ] ; then
+    if [ "$fail_count" = 0 ]; then
         output "test run $SUF: all tests OK.\n"
-	SUMMARY_OK="$SUMMARY_OK $SUF"
+        SUMMARY_OK="$SUMMARY_OK $SUF"
     else
-	if [ "$V" -gt 0 ] ; then
-	    printf "$outbuf"
-	    echo "test run $SUF: $fail_count test failures. FAIL."
+        if [ "$V" -gt 0 ]; then
+            printf "$outbuf"
+            echo "test run $SUF: $fail_count test failures. FAIL."
         fi
-	SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
-	exit_code=30
+        SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
+        exit_code=30
     fi

     if [ -n "$test_cleanup" ]; then
@@ -484,9 +485,9 @@

 done

-if [ -z "$SUMMARY_OK" ] ; then SUMMARY_OK=" none"; fi
-if [ -z "$SUMMARY_SKIP" ] ; then SUMMARY_SKIP=" none"; fi
-if [ -z "$SUMMARY_FAIL" ] ; then SUMMARY_FAIL=" none"; fi
+if [ -z "$SUMMARY_OK" ]; then SUMMARY_OK=" none"; fi
+if [ -z "$SUMMARY_SKIP" ]; then SUMMARY_SKIP=" none"; fi
+if [ -z "$SUMMARY_FAIL" ]; then SUMMARY_FAIL=" none"; fi
 echo "Test sets succeeded:$SUMMARY_OK."
 echo "Test sets skipped:$SUMMARY_SKIP."
 echo "Test sets failed:$SUMMARY_FAIL."
diff --git a/tests/t_cltsrv.sh b/tests/t_cltsrv.sh
index 6b7df65..03c3845 100755
--- a/tests/t_cltsrv.sh
+++ b/tests/t_cltsrv.sh
@@ -24,50 +24,58 @@
 trap "rm -f log.$$ log.$$.signal ; trap 0 ; exit 77" 1 2 15
 trap "rm -f log.$$ log.$$.signal ; exit 1" 0 3
 addopts=
-case `uname -s` in
+case $(uname -s) in
     FreeBSD)
-    # FreeBSD jails map the outgoing IP to the jail IP - we need to
-    # allow the real IP unless we want the test to run forever.
-    if test "`sysctl 2>/dev/null -n security.jail.jailed`" = 1 \
-    || ps -ostate= -p $$ | grep -q J; then
-	addopts="--float"
-	if test "x`ifconfig | grep inet`" = x ; then
-	    echo "###"
-	    echo "### To run the test in a FreeBSD jail, you MUST add an IP alias for the jail's IP."
-	    echo "###"
-	    exit 77
-	fi
-    fi
-    ;;
+        # FreeBSD jails map the outgoing IP to the jail IP - we need to
+        # allow the real IP unless we want the test to run forever.
+        if test "$(sysctl 2>/dev/null -n security.jail.jailed)" = 1 ||
+            ps -ostate= -p $$ | grep -q J; then
+            addopts="--float"
+            if test "x$(ifconfig | grep inet)" = x; then
+                echo "###"
+                echo "### To run the test in a FreeBSD jail, you MUST add an IP alias for the jail's IP."
+                echo "###"
+                exit 77
+            fi
+        fi
+        ;;
 esac

 # make sure that the --down script is executable -- fail (rather than
 # skip) test if it isn't.
 downscript="../tests/t_cltsrv-down.sh"
 root="${top_srcdir}/sample"
-test -x "${root}/${downscript}" || chmod +x "${root}/${downscript}" || { echo >&2 "${root}/${downscript} is not executable, failing." ; exit 1 ; }
+test -x "${root}/${downscript}" || chmod +x "${root}/${downscript}" || {
+    echo >&2 "${root}/${downscript} is not executable, failing."
+    exit 1
+}
 echo "The following test will take about two minutes." >&2
 echo "If the addresses are in use, this test will retry up to two times." >&2

 # go
 success=0
-for i in 1 2 3 ; do
-  set +e
-  (
-  "${openvpn}" --script-security 2 --cd "${root}" ${addopts} --setenv role srv --down "${downscript}" --tls-exit --ping-exit 180 --config "sample-config-files/loopback-server" &
-  "${openvpn}" --script-security 2 --cd "${top_srcdir}/sample" ${addopts} --setenv role clt --down "${downscript}" --tls-exit --ping-exit 180 --config "sample-config-files/loopback-client"
-  ) 3>log.$$.signal >log.$$ 2>&1
-  e1=$?
-  wait $!
-  e2=$?
-  grep 'TCP/UDP: Socket bind failed on local address.*in use' log.$$ >/dev/null && {
-    echo 'address in use, retrying in 150 s'
-    sleep 150
-    continue
-  }
-  grep -v ':inactive$' log.$$.signal >/dev/null && { cat log.$$.signal ; echo ; cat log.$$ ; exit 1 ; }
-  success=1
-  break
+for i in 1 2 3; do
+    set +e
+    (
+        "${openvpn}" --script-security 2 --cd "${root}" ${addopts} --setenv role srv --down "${downscript}" --tls-exit --ping-exit 180 --config "sample-config-files/loopback-server" &
+        "${openvpn}" --script-security 2 --cd "${top_srcdir}/sample" ${addopts} --setenv role clt --down "${downscript}" --tls-exit --ping-exit 180 --config "sample-config-files/loopback-client"
+    ) 3>log.$$.signal >log.$$ 2>&1
+    e1=$?
+    wait $!
+    e2=$?
+    grep 'TCP/UDP: Socket bind failed on local address.*in use' log.$$ >/dev/null && {
+        echo 'address in use, retrying in 150 s'
+        sleep 150
+        continue
+    }
+    grep -v ':inactive$' log.$$.signal >/dev/null && {
+        cat log.$$.signal
+        echo
+        cat log.$$
+        exit 1
+    }
+    success=1
+    break
 done

 set -e
@@ -75,14 +83,14 @@
 # exit code - defaults to 0, PASS
 ec=0

-if [ $success != 1 ] ; then
-  # couldn't run test -- addresses in use, skip test
-  cat log.$$
-  ec=77
-elif [ $e1 != 0 ] || [ $e2 != 0 ] ; then
-  # failure -- fail test
-  cat log.$$
-  ec=1
+if [ $success != 1 ]; then
+    # couldn't run test -- addresses in use, skip test
+    cat log.$$
+    ec=77
+elif [ $e1 != 0 ] || [ $e2 != 0 ]; then
+    # failure -- fail test
+    cat log.$$
+    ec=1
 fi

 rm log.$$ log.$$.signal
diff --git a/tests/t_lpback.sh b/tests/t_lpback.sh
index 6802506..058206f 100755
--- a/tests/t_lpback.sh
+++ b/tests/t_lpback.sh
@@ -37,51 +37,56 @@
 test_start()
 {
     case $V in
-        0) outbuf="" ;;                  # no per-test output at all
-        1) outbuf="$@" ;;                # compact, details only on failure
-        *) printf "$@" ;;                # print all
+        0) outbuf="" ;;   # no per-test output at all
+        1) outbuf="$@" ;; # compact, details only on failure
+        *) printf "$@" ;; # print all
     esac
 }
 test_end()
 {
-    RC=$1 ; LOG=$2
-    if [ $RC != 0 ]
-    then
+    RC=$1
+    LOG=$2
+    if [ $RC != 0 ]; then
         case $V in
-            0) ;;                                # no per-test output
-            1) echo "$outbuf" "FAIL (RC=$RC)"; cat $LOG ;;
-            *) echo "FAIL (RC=$RC)"; cat $LOG ;;
+            0) ;; # no per-test output
+            1)
+                echo "$outbuf" "FAIL (RC=$RC)"
+                cat $LOG
+                ;;
+            *)
+                echo "FAIL (RC=$RC)"
+                cat $LOG
+                ;;
         esac
         e=1
-        tests_failed=$(( $tests_failed + 1 ))
+        tests_failed=$(($tests_failed + 1))
     else
         case $V in
-            0|1) ;;                              # no per-test output for 'OK'
-            *) echo "OK"                         # print all
+            0 | 1) ;;       # no per-test output for 'OK'
+            *) echo "OK" ;; # print all
         esac
-        tests_passed=$(( $tests_passed + 1 ))
+        tests_passed=$(($tests_passed + 1))
     fi
 }

 # if running with V=1, give an indication what test runs now
-if [ "$V" = 1  ] ; then
+if [ "$V" = 1 ]; then
     echo "$0: running with V=$V, only printing test fails"
 fi

-
 # Get list of supported ciphers from openvpn --show-ciphers output
-CIPHERS=$(${openvpn} --show-ciphers | \
-            sed -e '/The following/,/^$/d' -e s'/ .*//' -e '/^[[:space:]]*$/d')
+CIPHERS=$(${openvpn} --show-ciphers |
+    sed -e '/The following/,/^$/d' -e s'/ .*//' -e '/^[[:space:]]*$/d')

 # SK, 2014-06-04: currently the DES-EDE3-CFB1 implementation of OpenSSL is
 # broken (see http://rt.openssl.org/Ticket/Display.html?id=2867), so exclude
 # that cipher from this test.
 # GD, 2014-07-06 so is DES-CFB1
 # GD, 2014-07-06 do not test RC5-* either (fails on NetBSD w/o libcrypto_rc5)
-CIPHERS=$(echo "$CIPHERS" | egrep -v '^(DES-EDE3-CFB1|DES-CFB1|RC5-)' )
+CIPHERS=$(echo "$CIPHERS" | egrep -v '^(DES-EDE3-CFB1|DES-CFB1|RC5-)')

 e=0
-if [ -z "$CIPHERS" ] ; then
+if [ -z "$CIPHERS" ]; then
     echo "'openvpn --show-ciphers' FAILED (empty list)"
     e=1
 fi
@@ -91,10 +96,9 @@
 
 set +e

-for cipher in ${CIPHERS}
-do
+for cipher in ${CIPHERS}; do
     test_start "Testing cipher ${cipher}... "
-    ( "${openvpn}" --test-crypto --cipher ${cipher} ) >log.$$ 2>&1
+    ("${openvpn}" --test-crypto --cipher ${cipher}) >log.$$ 2>&1
     test_end $? log.$$
 done

@@ -121,7 +125,7 @@
     >log.$$ 2>&1
 test_end $? log.$$

-if [ "$V" -ge 1  ] ; then
+if [ "$V" -ge 1 ]; then
     echo "$0: tests passed: $tests_passed  failed: $tests_failed"
 fi

diff --git a/tests/t_net.sh b/tests/t_net.sh
index 8134832..17e028e 100755
--- a/tests/t_net.sh
+++ b/tests/t_net.sh
@@ -9,7 +9,6 @@
 top_builddir="${top_builddir:-..}"
 openvpn="${openvpn:-${top_builddir}/src/openvpn/openvpn}"

-
 # bail out right away on non-linux. NetLink (the object of this test) is only
 # used on Linux, therefore testing other platform is not needed.
 #
@@ -69,7 +68,6 @@
     done
 }

-
 ## execution starts here

 # t_client.rc required only for RUN_SUDO definition
@@ -89,21 +87,18 @@
     exit 77
 fi

-
 # Ensure PREFER_KSU is in a known state
 PREFER_KSU="${PREFER_KSU:-0}"

 # make sure we have permissions to run the networking unit-test
-ID=`id`
-if expr "$ID" : "uid=0" >/dev/null
-then :
+ID=$(id)
+if expr "$ID" : "uid=0" >/dev/null; then
+    :
 else
-    if [ "${PREFER_KSU}" -eq 1 ];
-    then
+    if [ "${PREFER_KSU}" -eq 1 ]; then
         # Check if we have a valid kerberos ticket
         klist -l 1>/dev/null 2>/dev/null
-        if [ $? -ne 0 ];
-        then
+        if [ $? -ne 0 ]; then
             # No kerberos ticket found, skip ksu and fallback to RUN_SUDO
             PREFER_KSU=0
             echo "$0: No Kerberos ticket available.  Will not use ksu."
@@ -112,16 +107,14 @@
         fi
     fi

-    if [ -z "$RUN_SUDO" ]
-    then
+    if [ -z "$RUN_SUDO" ]; then
         echo "$0: no RUN_SUDO=... in t_client.rc or environment, defaulting to 'sudo'." >&2
         echo "      if that does not work, set RUN_SUDO= correctly for your system." >&2
         RUN_SUDO="sudo"
     fi

     # check that we can run the unit-test binary with sudo
-    if $RUN_SUDO $UNIT_TEST test
-    then
+    if $RUN_SUDO $UNIT_TEST test; then
         echo "$0: $RUN_SUDO $UNIT_TEST succeeded, good."
     else
         echo "$0: $RUN_SUDO $UNIT_TEST failed, cannot go on. SKIP." >&2
diff --git a/tests/t_server_null.sh b/tests/t_server_null.sh
index 74ffd52..c633614 100755
--- a/tests/t_server_null.sh
+++ b/tests/t_server_null.sh
@@ -2,7 +2,7 @@
 #
 TSERVER_NULL_SKIP_RC="${TSERVER_NULL_SKIP_RC:-77}"

-if ! [ -r "./t_server_null.rc" ] ; then
+if ! [ -r "./t_server_null.rc" ]; then
     echo "${0}: cannot find './t_server_null.rc. SKIPPING TEST.'" >&2
     exit "${TSERVER_NULL_SKIP_RC}"
 fi
@@ -22,11 +22,10 @@
 # make sure we have permissions to run ifconfig/route from OpenVPN
 # can't use "id -u" here - doesn't work on Solaris
 ID=$(id)
-if expr "$ID" : "uid=0" >/dev/null
-then :
+if expr "$ID" : "uid=0" >/dev/null; then
+    :
 else
-    if [ "${PREFER_KSU}" -eq 1 ];
-    then
+    if [ "${PREFER_KSU}" -eq 1 ]; then
         # Check if we have a valid kerberos ticket
         if klist -l 1>/dev/null 2>/dev/null; then
             RUN_SUDO="ksu -q -e"
@@ -37,26 +36,24 @@
         fi
     fi

-    if [ -z "$RUN_SUDO" ]
-    then
+    if [ -z "$RUN_SUDO" ]; then
         echo "${0}: this test must run be as root, or RUN_SUDO=... " >&2
         echo "      must be set correctly in 't_server_null.rc'. SKIP." >&2
         exit "${TSERVER_NULL_SKIP_RC}"
     else
-	# Run a no-op command with privilege escalation (e.g. sudo) so that
-	# we (hopefully) do not have to ask the users password during the test.
-	if $RUN_SUDO "${KILL_EXEC}" -0 $$
-	then
-	    echo "${0}: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
-	else
-	    echo "${0}: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
-	    exit "${TSERVER_NULL_SKIP_RC}"
-	fi
+        # Run a no-op command with privilege escalation (e.g. sudo) so that
+        # we (hopefully) do not have to ask the users password during the test.
+        if $RUN_SUDO "${KILL_EXEC}" -0 $$; then
+            echo "${0}: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
+        else
+            echo "${0}: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
+            exit "${TSERVER_NULL_SKIP_RC}"
+        fi
     fi
 fi

 srcdir="${srcdir:-.}"
-export t_server_null_logdir=t_server_null-`hostname`-`date +%Y%m%d-%H%M%S`
+export t_server_null_logdir=t_server_null-$(hostname)-$(date +%Y%m%d-%H%M%S)

 # Create directory for server and client logs
 mkdir $t_server_null_logdir
diff --git a/tests/t_server_null_client.sh b/tests/t_server_null_client.sh
index 1745de5..3203cc2 100755
--- a/tests/t_server_null_client.sh
+++ b/tests/t_server_null_client.sh
@@ -1,9 +1,10 @@
 #!/bin/sh

-should_run_test() {
+should_run_test()
+{
     test_name="$1"

-    if echo "$test_name"|grep -q _lwip; then
+    if echo "$test_name" | grep -q _lwip; then
         if [ "$has_lwipovpn" = "no" ]; then
             return 1
         fi
@@ -12,7 +13,8 @@
     return 0
 }

-launch_client() {
+launch_client()
+{
     test_name=$1
     log="${test_name}.log"
     pid="${test_name}.pid"
@@ -30,7 +32,8 @@
         --log "${t_server_null_logdir}/${log}" &
 }

-ping_and_kill() {
+ping_and_kill()
+{
     if fping -q -c 5 $1; then
         echo "PASS: fping lwipovpn client $target"
     else
@@ -46,9 +49,10 @@
     kill -15 $2
 }

-ping_lwip_clients() {
+ping_lwip_clients()
+{
     if [ "$has_lwipovpn" = "yes" ]; then
-        lwip_client_count=$(echo "$lwip_test_names"|wc -w|tr -d " ")
+        lwip_client_count=$(echo "$lwip_test_names" | wc -w | tr -d " ")
     else
         lwip_client_count=0
     fi
@@ -60,10 +64,10 @@
     count=0
     maxcount=10
     while [ $count -le $maxcount ]; do
-        lwip_client_ips=$(cat ./*.lwip 2>/dev/null|wc -l)
+        lwip_client_ips=$(cat ./*.lwip 2>/dev/null | wc -l)
         if [ $lwip_client_ips -lt $lwip_client_count ]; then
             echo "Waiting for LWIP clients to start up ($count/$maxcount)"
-            count=$(( count + 1))
+            count=$((count + 1))
             sleep 1
         else
             echo "$lwip_client_ips/$lwip_client_count LWIP clients up"
@@ -73,8 +77,8 @@

     wait_pids=""
     for line in $(cat ./*.lwip 2>/dev/null); do
-        target_ip=$(echo $line|cut -d "," -f 1)
-        client_pid=$(echo $line|cut -d "," -f 2)
+        target_ip=$(echo $line | cut -d "," -f 1)
+        client_pid=$(echo $line | cut -d "," -f 2)
         ping_and_kill $target_ip $client_pid &
         wait_pids="$wait_pids $!"
     done
@@ -84,7 +88,8 @@
     test -e ./lwip_failed && return 1 || return 0
 }

-wait_for_results() {
+wait_for_results()
+{
     tests_running="yes"

     # Wait a bit to allow an OpenVPN client process to create a pidfile to
@@ -106,12 +111,13 @@
     done
 }

-get_client_test_result() {
+get_client_test_result()
+{
     test_name=$1
     should_pass=$2
     log="${test_name}.log"

-    grep "Initialization Sequence Completed" "${t_server_null_logdir}/${log}" > /dev/null
+    grep "Initialization Sequence Completed" "${t_server_null_logdir}/${log}" >/dev/null
     exit_code=$?

     if [ $exit_code -eq 0 ] && [ "${should_pass}" = "yes" ]; then
@@ -144,7 +150,7 @@
 server_max_wait=15
 while [ $count -lt $server_max_wait ]; do
     servers_up=0
-    server_count=$(echo "$TEST_SERVER_LIST"|wc -w|tr -d " ")
+    server_count=$(echo "$TEST_SERVER_LIST" | wc -w | tr -d " ")

     # We need to trim single-quotes because some shells return quoted values
     # and some don't. Using "set -o posix" which would resolve this problem is
@@ -152,13 +158,13 @@
     #
     # While inactive server configurations may get checked they won't increase
     # the active server count as the processes won't be running.
-    for i in $(set|grep 'SERVER_NAME_'|cut -d "=" -f 2|tr -d "[\']"); do
-        server_pid=$(cat "$i.pid" 2> /dev/null)
-        if [ -z "$server_pid" ] ; then
+    for i in $(set | grep 'SERVER_NAME_' | cut -d "=" -f 2 | tr -d "[\']"); do
+        server_pid=$(cat "$i.pid" 2>/dev/null)
+        if [ -z "$server_pid" ]; then
             continue
         fi
-        if $RUN_SUDO kill -0 $server_pid > /dev/null 2>&1; then
-            servers_up=$(( $servers_up + 1 ))
+        if $RUN_SUDO kill -0 $server_pid >/dev/null 2>&1; then
+            servers_up=$(($servers_up + 1))
         fi
     done

@@ -168,7 +174,7 @@
         retval=0
         break
     else
-        count=$(( count + 1))
+        count=$((count + 1))
         sleep 1
     fi

@@ -199,15 +205,14 @@
 # safe to check the test results.
 test_names=""
 lwip_test_names=""
-for SUF in $TEST_RUN_LIST
-do
+for SUF in $TEST_RUN_LIST; do
     eval test_name=\"\$TEST_NAME_$SUF\"
     eval client_exec=\"\$CLIENT_EXEC_$SUF\"
     eval client_conf=\"\$CLIENT_CONF_$SUF\"

     test_names="${test_names} ${test_name}"

-    if echo "$test_name"|grep -q _lwip; then
+    if echo "$test_name" | grep -q _lwip; then
         lwip_test_names="${lwip_test_names} ${test_name}"
     fi

@@ -219,13 +224,11 @@
 ping_lwip_clients
 retval=$?

-
 # Wait until all OpenVPN clients have exited
 (wait_for_results)

 # Check test results
-for SUF in $TEST_RUN_LIST
-do
+for SUF in $TEST_RUN_LIST; do
     eval test_name=\"\$TEST_NAME_$SUF\"
     eval should_pass=\"\$SHOULD_PASS_$SUF\"

diff --git a/tests/t_server_null_server.sh b/tests/t_server_null_server.sh
index e1775f0..a8d7268 100755
--- a/tests/t_server_null_server.sh
+++ b/tests/t_server_null_server.sh
@@ -1,6 +1,7 @@
 #!/bin/sh

-launch_server() {
+launch_server()
+{
     server_name=$1
     server_exec=$2
     server_conf=$3
@@ -17,10 +18,10 @@

     # Try to launch the server
     $RUN_SUDO "${server_exec}" \
-               $server_conf \
-               --status "${status}" 1 \
-               --writepid "${pid}" \
-               --explicit-exit-notify 3 > "$log" 2>&1 &
+        $server_conf \
+        --status "${status}" 1 \
+        --writepid "${pid}" \
+        --explicit-exit-notify 3 >"$log" 2>&1 &

     sleep 1

@@ -44,8 +45,7 @@
 retval=0

 # Launch test servers
-for SUF in $TEST_SERVER_LIST
-do
+for SUF in $TEST_SERVER_LIST; do
     eval server_name=\"\$SERVER_NAME_$SUF\"
     eval server_exec=\"\$SERVER_EXEC_$SUF\"
     eval server_conf=\"\$SERVER_CONF_$SUF\"
@@ -57,8 +57,7 @@
 # the test run.
 #
 export server_pid_files=""
-for SUF in $TEST_SERVER_LIST
-do
+for SUF in $TEST_SERVER_LIST; do
     eval server_name=\"\$SERVER_NAME_$SUF\"
     server_pid_files="${server_pid_files} ./${server_name}.pid"
 done
@@ -69,12 +68,11 @@
 count=0
 maxcount=4
 while [ $count -le $maxcount ]; do
-    if ls t_server_null_client.sh*.pid > /dev/null 2>&1
-    then
+    if ls t_server_null_client.sh*.pid >/dev/null 2>&1; then
         count=0
         sleep 1
     else
-	count=$(( count + 1))
+        count=$((count + 1))
         sleep 1
     fi
 done
@@ -85,11 +83,10 @@
 # server process does not exit in 15 seconds assume it never will, move on and
 # hope for the best.
 echo "Waiting for servers to exit"
-for PID_FILE in $server_pid_files
-do
+for PID_FILE in $server_pid_files; do
     SERVER_PID=$(cat "${PID_FILE}")

-    if [ -z "$SERVER_PID" ] ; then
+    if [ -z "$SERVER_PID" ]; then
         echo "WARNING: could not kill server ${PID_FILE}!"
         continue
     fi
@@ -99,17 +96,16 @@

     count=0
     maxcount=75
-    while [ $count -le $maxcount ]
-    do
-        $RUN_SUDO kill -0 "${SERVER_PID}" 2> /dev/null || break
-        count=$(( count + 1))
+    while [ $count -le $maxcount ]; do
+        $RUN_SUDO kill -0 "${SERVER_PID}" 2>/dev/null || break
+        count=$((count + 1))
         sleep 0.2
     done

     # If server is still up send a SIGKILL
     if [ $count -ge $maxcount ]; then
         $RUN_SUDO $KILL_EXEC -9 "${SERVER_PID}"
-        SERVER_NAME=$(basename $PID_FILE|cut -d . -f 1)
+        SERVER_NAME=$(basename $PID_FILE | cut -d . -f 1)
         echo "ERROR: had to send SIGKILL to server ${SERVER_NAME} with pid ${SERVER_PID}!"
         echo "Tail of server log:"
         tail -n 20 "${t_server_null_logdir}/${SERVER_NAME}.log"
diff --git a/tests/t_server_null_stress.sh b/tests/t_server_null_stress.sh
index 0bb9452..2fc9fde 100755
--- a/tests/t_server_null_stress.sh
+++ b/tests/t_server_null_stress.sh
@@ -7,8 +7,7 @@
 . ./t_server_null_default.rc

 export pid_files=""
-for SUF in $TEST_SERVER_LIST
-do
+for SUF in $TEST_SERVER_LIST; do
     eval server_name=\"\$SERVER_NAME_$SUF\"
     pid_files="${pid_files} ./${server_name}.pid"
 done
@@ -18,16 +17,16 @@

 count=0
 while [ $count -lt $ITERATIONS ]; do
-    count=$(( count + 1 ))
-    make check TESTS=t_server_null.sh SUBDIRS= > /dev/null 2>&1
+    count=$((count + 1))
+    make check TESTS=t_server_null.sh SUBDIRS= >/dev/null 2>&1
     retval=$?

-    echo "Iteration ${count}: return value ${retval}" >> "${LOG_BASEDIR}/make-check.log"
+    echo "Iteration ${count}: return value ${retval}" >>"${LOG_BASEDIR}/make-check.log"
     if [ $retval -ne 0 ]; then
-	DIR="${LOG_BASEDIR}/make-check-${count}"
+        DIR="${LOG_BASEDIR}/make-check-${count}"
         mkdir -p "${DIR}"
         cp t_server_null*.log "${DIR}/"
         cp test-suite.log "${DIR}/"
-        ps aux|grep openvpn|grep -vE '(suppress|grep)' > "${DIR}/psaux"
+        ps aux | grep openvpn | grep -vE '(suppress|grep)' >"${DIR}/psaux"
     fi
 done
diff --git a/tests/update_t_client_ips.sh b/tests/update_t_client_ips.sh
index 96e3826..777a286 100755
--- a/tests/update_t_client_ips.sh
+++ b/tests/update_t_client_ips.sh
@@ -5,12 +5,12 @@

 RC="$TOP_BUILDDIR/t_client_ips.rc"

-grep EXPECT_IFCONFIG4_$TESTNUM= $RC > /dev/null 2>&1
+grep EXPECT_IFCONFIG4_$TESTNUM= $RC >/dev/null 2>&1
 if [ $? -ne 0 ]; then
-    echo "EXPECT_IFCONFIG4_$TESTNUM=$ifconfig_local" >> $RC
+    echo "EXPECT_IFCONFIG4_$TESTNUM=$ifconfig_local" >>$RC
 fi

-grep EXPECT_IFCONFIG6_$TESTNUM= $RC > /dev/null 2>&1
+grep EXPECT_IFCONFIG6_$TESTNUM= $RC >/dev/null 2>&1
 if [ $? -ne 0 ]; then
-    echo "EXPECT_IFCONFIG6_$TESTNUM=$ifconfig_ipv6_local" >> $RC
+    echo "EXPECT_IFCONFIG6_$TESTNUM=$ifconfig_ipv6_local" >>$RC
 fi

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1793?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f
Gerrit-Change-Number: 1793
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <frank@lichtenheld.com>
Gerrit-Reviewer: plaisthos <arne-openvpn@rfc2549.org>
Gerrit-CC: openvpn-devel <openvpn-devel@lists.sourceforge.net>
Gerrit-CC: razvanc <razvanc@mailbox.org>
Gerrit-Attention: plaisthos <arne-openvpn@rfc2549.org>
Gerrit-Attention: flichtenheld <frank@lichtenheld.com>

[-- Attachment #1.2: Type: text/html, Size: 120562 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Openvpn-devel] [L] Change in openvpn[master]: Reformat all shell-scripts with shfmt
       [not found] <gerrit.1784305303000.I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f@gerrit.openvpn.net>
                   ` (4 preceding siblings ...)
  2026-08-19 11:42 ` flichtenheld (Code Review) via Openvpn-devel
@ 2026-08-19 11:44 ` flichtenheld (Code Review) via Openvpn-devel
  2026-08-19 11:48 ` razvanc (Code Review) via Openvpn-devel
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: flichtenheld (Code Review) via Openvpn-devel @ 2026-08-19 11:44 UTC (permalink / raw)
  Cc: flichtenheld (Code Review), openvpn-devel, plaisthos


[-- Attachment #1.1: Type: text/plain, Size: 1786 bytes --]

Attention is currently required from: plaisthos, razvanc.

flichtenheld has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1793?usp=email )

Change subject: Reformat all shell-scripts with shfmt
......................................................................


Patch Set 3:

(1 comment)

File dev-tools/gen-release-tarballs.sh:

http://gerrit.openvpn.net/c/openvpn/+/1793/comment/4ecfe3fe_a7730408?usp=email :
PS2, Line 72:     res="$(find . -maxdepth 1 -type f -name \"$wildcard\" | head -n1 | cut -d/ -f2-)"
> This doesn't have the same meaning as before. […]
Made the fix in a separate change #1847 since this commit should only contain the result of the automated script run.

This was not noticed since there are no current users for this script. I considered whether I should remove it instead, but the issues I found when testing it seemed
too small to warrant that.



--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1793?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f
Gerrit-Change-Number: 1793
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <frank@lichtenheld.com>
Gerrit-Reviewer: plaisthos <arne-openvpn@rfc2549.org>
Gerrit-CC: openvpn-devel <openvpn-devel@lists.sourceforge.net>
Gerrit-CC: razvanc <razvanc@mailbox.org>
Gerrit-Attention: plaisthos <arne-openvpn@rfc2549.org>
Gerrit-Attention: razvanc <razvanc@mailbox.org>
Gerrit-Comment-Date: Wed, 19 Aug 2026 11:44:52 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: razvanc <razvanc@mailbox.org>

[-- Attachment #1.2: Type: text/html, Size: 3143 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Openvpn-devel] [L] Change in openvpn[master]: Reformat all shell-scripts with shfmt
       [not found] <gerrit.1784305303000.I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f@gerrit.openvpn.net>
                   ` (5 preceding siblings ...)
  2026-08-19 11:44 ` flichtenheld (Code Review) via Openvpn-devel
@ 2026-08-19 11:48 ` razvanc (Code Review) via Openvpn-devel
  2026-08-19 13:18 ` flichtenheld (Code Review) via Openvpn-devel
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: razvanc (Code Review) via Openvpn-devel @ 2026-08-19 11:48 UTC (permalink / raw)
  To: flichtenheld; +Cc: razvanc (Code Review), openvpn-devel, plaisthos


[-- Attachment #1.1: Type: text/plain, Size: 1145 bytes --]

Attention is currently required from: flichtenheld, plaisthos.

razvanc has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1793?usp=email )

Change subject: Reformat all shell-scripts with shfmt
......................................................................


Patch Set 3: Code-Review+2


--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1793?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f
Gerrit-Change-Number: 1793
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <frank@lichtenheld.com>
Gerrit-Reviewer: plaisthos <arne-openvpn@rfc2549.org>
Gerrit-Reviewer: razvanc <razvanc@mailbox.org>
Gerrit-CC: openvpn-devel <openvpn-devel@lists.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@rfc2549.org>
Gerrit-Attention: flichtenheld <frank@lichtenheld.com>
Gerrit-Comment-Date: Wed, 19 Aug 2026 11:48:04 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

[-- Attachment #1.2: Type: text/html, Size: 2092 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Openvpn-devel] [L] Change in openvpn[master]: Reformat all shell-scripts with shfmt
       [not found] <gerrit.1784305303000.I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f@gerrit.openvpn.net>
                   ` (6 preceding siblings ...)
  2026-08-19 11:48 ` razvanc (Code Review) via Openvpn-devel
@ 2026-08-19 13:18 ` flichtenheld (Code Review) via Openvpn-devel
  2026-08-19 13:44 ` razvanc (Code Review) via Openvpn-devel
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: flichtenheld (Code Review) via Openvpn-devel @ 2026-08-19 13:18 UTC (permalink / raw)
  To: plaisthos, razvanc; +Cc: flichtenheld (Code Review), openvpn-devel


[-- Attachment #1.1: Type: text/plain, Size: 53053 bytes --]

Attention is currently required from: flichtenheld, plaisthos, razvanc.

Hello plaisthos, razvanc,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1793?usp=email

to look at the new patch set (#4).

The following approvals got outdated and were removed:
Code-Review+2 by razvanc


Change subject: Reformat all shell-scripts with shfmt
......................................................................

Reformat all shell-scripts with shfmt

According to ./dev-tools/reformat-shell.sh.

Change-Id: I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
---
M dev-tools/git-pre-commit-format.sh
M dev-tools/run-cppcheck.sh
M dev-tools/update-copyright.sh
M tests/lwip_client_up.sh
M tests/null_client_up.sh
M tests/t_client.sh.in
M tests/t_cltsrv.sh
M tests/t_lpback.sh
M tests/t_net.sh
M tests/t_server_null.sh
M tests/t_server_null_client.sh
M tests/t_server_null_server.sh
M tests/t_server_null_stress.sh
M tests/update_t_client_ips.sh
14 files changed, 386 insertions(+), 385 deletions(-)


  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/93/1793/4

diff --git a/dev-tools/git-pre-commit-format.sh b/dev-tools/git-pre-commit-format.sh
index 9b2ecaf..3507289 100755
--- a/dev-tools/git-pre-commit-format.sh
+++ b/dev-tools/git-pre-commit-format.sh
@@ -26,7 +26,6 @@
 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-
 # git pre-commit hook that runs a stylecheck.
 # Features:
 #  - abort commit when commit does not comply with the style guidelines
@@ -43,12 +42,11 @@
 # exit on error
 set -e

-
 # If called so, install this script as pre-commit hook
-if [ "$1" = "install" ] ; then
+if [ "$1" = "install" ]; then
     TARGET="$(git rev-parse --git-path hooks)/pre-commit"

-    if [ -e "$TARGET" ] ; then
+    if [ -e "$TARGET" ]; then
         printf "$TARGET file exists. Won't overwrite.\n"
         printf "Aborting installation.\n"
         exit 1
@@ -62,18 +60,19 @@
 fi

 # check whether the given file matches any of the set extensions
-matches_extension() {
+matches_extension()
+{
     local filename="$(basename -- "$1")"
     local extension=".${filename##*.}"
     local ext

-    for ext in .c .h ; do [ "$ext" = "$extension" ] && return 0; done
+    for ext in .c .h; do [ "$ext" = "$extension" ] && return 0; done

     return 1
 }

 # necessary check for initial commit
-if git rev-parse --verify HEAD >/dev/null 2>&1 ; then
+if git rev-parse --verify HEAD >/dev/null 2>&1; then
     against=HEAD
 else
     # Initial commit: diff against an empty tree object
@@ -88,8 +87,8 @@

     # Allow to use in parallel with pre-commit
     if [ $(basename "$0") = "pre-commit.legacy" ]; then
-       echo "Skipping clang-format check in favor of pre-commit"
-       exit 0
+        echo "Skipping clang-format check in favor of pre-commit"
+        exit 0
     fi
 else
     TOOL=uncrustify
@@ -98,7 +97,7 @@
     TOOL_CMD="$TOOL_BIN -q -l C -c $UNCRUST_CONFIG"

     # make sure the config file is correctly set
-    if [ ! -f "$UNCRUST_CONFIG" ] ; then
+    if [ ! -f "$UNCRUST_CONFIG" ]; then
         printf "Error: uncrustify config file not found.\n"
         printf "Expected to find it at $UNCRUST_CONFIG.\n"
         printf "Aborting commit.\n"
@@ -106,7 +105,7 @@
     fi
 fi

-if [ -z "$TOOL_BIN" ] ; then
+if [ -z "$TOOL_BIN" ]; then
     printf "Error: $TOOL executable not found.\n"
     printf "Is it installed and in your \$PATH?\n"
     printf "Aborting commit.\n"
@@ -120,44 +119,43 @@
 # create one patch containing all changes to the files
 # sed to remove quotes around the filename, if inserted by the system
 # (done sometimes, if the filename contains special characters, like the quote itself)
-git diff-index --cached --diff-filter=ACMR --name-only $against -- | \
-sed -e 's/^"\(.*\)"$/\1/' | \
-while read file
-do
-    # ignore file if we do check for file extensions and the file
-    # does not match the extensions .c or .h
-    if ! matches_extension "$file"; then
-        continue;
-    fi
+git diff-index --cached --diff-filter=ACMR --name-only $against -- |
+    sed -e 's/^"\(.*\)"$/\1/' |
+    while read file; do
+        # ignore file if we do check for file extensions and the file
+        # does not match the extensions .c or .h
+        if ! matches_extension "$file"; then
+            continue
+        fi

-    # escape special characters in the target filename:
-    # phase 1 (characters escaped in the output diff):
-    #     - '\': backslash needs to be escaped in the output diff
-    #     - '"': quote needs to be escaped in the output diff if present inside
-    #            of the filename, as it used to bracket the entire filename part
-    # phase 2 (characters escaped in the match replacement):
-    #     - '\': backslash needs to be escaped again for sed itself
-    #            (i.e. double escaping after phase 1)
-    #     - '&': would expand to matched string
-    #     - '|': used as sed split char instead of '/'
-    # printf %s particularly important if the filename contains the % character
-    file_escaped_target=$(printf "%s" "$file" | sed -e 's/[\"]/\\&/g' -e 's/[\&|]/\\&/g')
+        # escape special characters in the target filename:
+        # phase 1 (characters escaped in the output diff):
+        #     - '\': backslash needs to be escaped in the output diff
+        #     - '"': quote needs to be escaped in the output diff if present inside
+        #            of the filename, as it used to bracket the entire filename part
+        # phase 2 (characters escaped in the match replacement):
+        #     - '\': backslash needs to be escaped again for sed itself
+        #            (i.e. double escaping after phase 1)
+        #     - '&': would expand to matched string
+        #     - '|': used as sed split char instead of '/'
+        # printf %s particularly important if the filename contains the % character
+        file_escaped_target=$(printf "%s" "$file" | sed -e 's/[\"]/\\&/g' -e 's/[\&|]/\\&/g')

-    # uncrustify our sourcefile, create a patch with diff and append it to our $patch
-    # The sed call is necessary to transform the patch from
-    #    --- - timestamp
-    #    +++ $tmpout timestamp
-    # to both lines working on the same file and having a a/ and b/ prefix.
-    # Else it can not be applied with 'git apply'.
-    git show ":$file" | $TOOL_CMD > "$tmpout"
-    git show ":$file" | diff -u -- - "$tmpout" | \
-        sed -e "1s|--- -|--- \"b/$file_escaped_target\"|" -e "2s|+++ $tmpout|+++ \"a/$file_escaped_target\"|" >> "$patch"
-done
+        # uncrustify our sourcefile, create a patch with diff and append it to our $patch
+        # The sed call is necessary to transform the patch from
+        #    --- - timestamp
+        #    +++ $tmpout timestamp
+        # to both lines working on the same file and having a a/ and b/ prefix.
+        # Else it can not be applied with 'git apply'.
+        git show ":$file" | $TOOL_CMD >"$tmpout"
+        git show ":$file" | diff -u -- - "$tmpout" |
+            sed -e "1s|--- -|--- \"b/$file_escaped_target\"|" -e "2s|+++ $tmpout|+++ \"a/$file_escaped_target\"|" >>"$patch"
+    done

 rm -f "$tmpout"

 # if no patch has been generated all is ok, clean up the file stub and exit
-if [ ! -s "$patch" ] ; then
+if [ ! -s "$patch" ]; then
     rm -f "$patch"
     exit 0
 fi
@@ -165,7 +163,7 @@
 # a patch has been created, notify the user and exit
 printf "Formatting of some code does not follow the project guidelines.\n"

-if [ $(wc -l < $patch) -gt 80 ] ; then
+if [ $(wc -l <$patch) -gt 80 ]; then
     printf "The file $patch contains the necessary fixes.\n"
 else
     printf "Here's the patch that fixes the formatting:\n\n"
diff --git a/dev-tools/run-cppcheck.sh b/dev-tools/run-cppcheck.sh
index 40db33e..a7aa3c4 100755
--- a/dev-tools/run-cppcheck.sh
+++ b/dev-tools/run-cppcheck.sh
@@ -20,24 +20,23 @@
  --check-level=exhaustive --max-configs=10 \
  --error-exitcode=1"

-
 set -x

 mkdir -p "$CPPCHECK_DIR"
 cd "${SOURCE_DIR}"
 cppcheck $COMMON_ARGS $INCLUDE_FLAGS \
-         --platform=unix64 \
-         --library=posix.cfg --library=bsd.cfg --library=gnu.cfg \
-         -U_WIN32 \
-         src/openvpn/ src/compat/ src/plugins/ sample/ \
-         tests/unit_tests/example_test/ tests/unit_tests/openvpn/ \
-         tests/unit_tests/plugins/
+    --platform=unix64 \
+    --library=posix.cfg --library=bsd.cfg --library=gnu.cfg \
+    -U_WIN32 \
+    src/openvpn/ src/compat/ src/plugins/ sample/ \
+    tests/unit_tests/example_test/ tests/unit_tests/openvpn/ \
+    tests/unit_tests/plugins/
 cppcheck $COMMON_ARGS \
-         --platform=win64 \
-         --library=windows.cfg \
-         -D_WIN32 \
-         -UTARGET_LINUX -UTARGET_FREEBSD -UTARGET_OPENBSD -UTARGET_NETBSD \
-         -UTARGET_DARWIN -UTARGET_ANDROID -UTARGET_SOLARIS -UTARGET_DRAGONFLY \
-         -UTARGET_AIX \
-         src/openvpn* src/compat/ \
-         tests/unit_tests/example_test/ tests/unit_tests/openvpn*
+    --platform=win64 \
+    --library=windows.cfg \
+    -D_WIN32 \
+    -UTARGET_LINUX -UTARGET_FREEBSD -UTARGET_OPENBSD -UTARGET_NETBSD \
+    -UTARGET_DARWIN -UTARGET_ANDROID -UTARGET_SOLARIS -UTARGET_DRAGONFLY \
+    -UTARGET_AIX \
+    src/openvpn* src/compat/ \
+    tests/unit_tests/example_test/ tests/unit_tests/openvpn*
diff --git a/dev-tools/update-copyright.sh b/dev-tools/update-copyright.sh
index 96546dd..7ca6002 100755
--- a/dev-tools/update-copyright.sh
+++ b/dev-tools/update-copyright.sh
@@ -34,8 +34,7 @@
 COPY_YEAR="$1"

 cd "$(git rev-parse --show-toplevel)"
-for file in $(git ls-files | grep -v vendor/);
-do
+for file in $(git ls-files | grep -v vendor/); do
     echo -n "Updating $file ..."
     # The first sed operation covers 20xx-20yy copyright lines,
     # The second sed operation changes 20xx -> 20xx-20yy
diff --git a/tests/lwip_client_up.sh b/tests/lwip_client_up.sh
index a6b4d24..b1941a4 100755
--- a/tests/lwip_client_up.sh
+++ b/tests/lwip_client_up.sh
@@ -2,16 +2,17 @@
 #
 # Determine the OpenVPN PID from its pid file. This works reliably even when
 # the OpenVPN process is backgrounded for parallel tests.
-MY_PPID=`cat $pid`
+MY_PPID=$(cat $pid)

 # Add this client's VPN IP and PID to a file. This enables
 # t_server_null_client.sh to kill this OpenVPN client after fping tests have
 # finished.
-echo "$ifconfig_local,$MY_PPID" >> ./$test_name.lwip
+echo "$ifconfig_local,$MY_PPID" >>./$test_name.lwip

 # Wait long enough to allow fping tests to finish. Also ensure that this
 # OpenVPN client is killed even if t_server_null_client.sh failed to do it.
-(sleep 15
-echo "ERROR: t_server_null_client.sh failed to kill OpenVPN client with PID $MY_PPID in test $test_name. Killing it in lwip_client_up.sh."
-kill -15 $MY_PPID
+(
+    sleep 15
+    echo "ERROR: t_server_null_client.sh failed to kill OpenVPN client with PID $MY_PPID in test $test_name. Killing it in lwip_client_up.sh."
+    kill -15 $MY_PPID
 ) &
diff --git a/tests/null_client_up.sh b/tests/null_client_up.sh
index d4df0c6..be339ee 100755
--- a/tests/null_client_up.sh
+++ b/tests/null_client_up.sh
@@ -4,8 +4,11 @@

 # Determine the OpenVPN PID from its pid file. This works reliably even when
 # the OpenVPN process is backgrounded for parallel tests.
-MY_PPID=`cat $pid`
+MY_PPID=$(cat $pid)
 
 # Allow OpenVPN to finish initializing while waiting in the background and then
 # killing the process gracefully.
-(sleep 5 ; kill -15 $MY_PPID) &
+(
+    sleep 5
+    kill -15 $MY_PPID
+) &
diff --git a/tests/t_client.sh.in b/tests/t_client.sh.in
index 2f37845..305441be 100755
--- a/tests/t_client.sh.in
+++ b/tests/t_client.sh.in
@@ -19,9 +19,9 @@
 srcdir="${srcdir:-.}"
 top_builddir="${top_builddir:-..}"
 openvpn="${openvpn:-${top_builddir}/src/openvpn/openvpn}"
-if [ -r "${top_builddir}"/t_client.rc ] ; then
+if [ -r "${top_builddir}"/t_client.rc ]; then
     . "${top_builddir}"/t_client.rc
-elif [ -r "${srcdir}"/t_client.rc ] ; then
+elif [ -r "${srcdir}"/t_client.rc ]; then
     . "${srcdir}"/t_client.rc
 else
     echo "$0: cannot find 't_client.rc' in build dir ('${top_builddir}')" >&2
@@ -32,37 +32,35 @@
 # Check for external dependencies
 FPING="fping"
 FPING6="fping6"
-which fping > /dev/null
+which fping >/dev/null
 if [ $? -ne 0 ]; then
     echo "$0: fping is not available in \$PATH" >&2
     exit "${TCLIENT_SKIP_RC}"
 fi
-which fping6 > /dev/null
+which fping6 >/dev/null
 if [ $? -ne 0 ]; then
     echo "$0: fping6 is not available in \$PATH, assuming fping 4.0 or later" >&2
     FPING="fping -4"
     FPING6="fping -6"
 fi

-KILL_EXEC=`which kill`
+KILL_EXEC=$(which kill)
 if [ $? -ne 0 ]; then
     echo "$0: kill not found in \$PATH" >&2
     exit "${TCLIENT_SKIP_RC}"
 fi

-if [ ! -x "${openvpn}" ]
-then
+if [ ! -x "${openvpn}" ]; then
     echo "no (executable) openvpn binary in current build tree. FAIL." >&2
     exit 1
 fi

-if [ ! -w . ]
-then
+if [ ! -w . ]; then
     echo "current directory is not writable (required for logging). FAIL." >&2
     exit 1
 fi

-if [ -z "$TEST_RUN_LIST" ] ; then
+if [ -z "$TEST_RUN_LIST" ]; then
     echo "TEST_RUN_LIST empty, no tests defined.  SKIP test." >&2
     exit "${TCLIENT_SKIP_RC}"
 fi
@@ -72,16 +70,14 @@

 # make sure we have permissions to run ifconfig/route from OpenVPN
 # can't use "id -u" here - doesn't work on Solaris
-ID=`id`
-if expr "$ID" : "uid=0" >/dev/null
-then :
+ID=$(id)
+if expr "$ID" : "uid=0" >/dev/null; then
+    :
 else
-    if [ "${PREFER_KSU}" -eq 1 ];
-    then
+    if [ "${PREFER_KSU}" -eq 1 ]; then
         # Check if we have a valid kerberos ticket
         klist -l 1>/dev/null 2>/dev/null
-        if [ $? -ne 0 ];
-        then
+        if [ $? -ne 0 ]; then
             # No kerberos ticket found, skip ksu and fallback to RUN_SUDO
             PREFER_KSU=0
             echo "$0: No Kerberos ticket available.  Will not use ksu."
@@ -90,8 +86,7 @@
         fi
     fi

-    if [ -z "$RUN_SUDO" ]
-    then
+    if [ -z "$RUN_SUDO" ]; then
         echo "$0: this test must run be as root, or RUN_SUDO=... " >&2
         echo "      must be set correctly in 't_client.rc'. SKIP." >&2
         exit "${TCLIENT_SKIP_RC}"
@@ -99,20 +94,19 @@
         # We have to use sudo. Make sure that we (hopefully) do not have
         # to ask the users password during the test. This is done to
         # prevent timing issues, e.g. when the waits for openvpn to start
-	if $RUN_SUDO $KILL_EXEC -0 $$
-	then
-	    echo "$0: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
-	else
-	    echo "$0: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
-	    exit "${TCLIENT_SKIP_RC}"
-	fi
+        if $RUN_SUDO $KILL_EXEC -0 $$; then
+            echo "$0: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
+        else
+            echo "$0: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
+            exit "${TCLIENT_SKIP_RC}"
+        fi
     fi
 fi

-LOGDIR=t_client-`hostname`-`date +%Y%m%d-%H%M%S`
+LOGDIR=t_client-$(hostname)-$(date +%Y%m%d-%H%M%S)
 LOGDIR_ABS="$PWD/$LOGDIR"
-if mkdir $LOGDIR
-then :
+if mkdir $LOGDIR; then
+    :
 else
     echo "can't create log directory '$LOGDIR'. FAIL." >&2
     exit 1
@@ -132,21 +126,28 @@
 output_start()
 {
     case $V in
-	0) outbuf="" ;;			# no per-test output at all
-	1) printf "$@\n"			# compact, details only on failure
-           outbuf="\n" ;;
-	*) printf "\n$@\n" ;;		# print all, with a bit formatting
+        0) outbuf="" ;; # no per-test output at all
+        1)
+            printf "$@\n" # compact, details only on failure
+            outbuf="\n"
+            ;;
+        *) printf "\n$@\n" ;; # print all, with a bit formatting
     esac
 }

 output()
 {
-    END_NL="\n"; if [ "X$1" = "X-n" ] ; then END_NL="" ; shift ; fi
+    END_NL="\n"
+    if [ "X$1" = "X-n" ]; then
+        END_NL=""
+        shift
+    fi
     case $V in
-	0) ;;				# no per-test output at all
-	1) outbuf="$outbuf$@${END_NL}"	# print details only on failure
-           ;;
-	*) printf "$@${END_NL}" ;;	# print everything
+        0) ;; # no per-test output at all
+        1)
+            outbuf="$outbuf$@${END_NL}" # print details only on failure
+            ;;
+        *) printf "$@${END_NL}" ;; # print everything
     esac
 }

@@ -154,62 +155,61 @@
 fail()
 {
     output "FAIL: $@\n"
-    fail_count=$(( $fail_count + 1 ))
+    fail_count=$(($fail_count + 1))
 }

 # print "all interface IP addresses" + "all routes"
 # this is higly system dependent...
 get_ifconfig_route()
 {
-    UNAME=`uname -s`
+    UNAME=$(uname -s)
     case $UNAME in
-	Linux)
+        Linux)
             # linux / iproute2? (-> if configure got a path)
-            if [ -n "@IPROUTE@" ]
-            then
+            if [ -n "@IPROUTE@" ]; then
                 echo "-- linux iproute2 --"
-                @IPROUTE@ addr show     | grep -v valid_lft
+                @IPROUTE@ addr show | grep -v valid_lft
                 @IPROUTE@ route show
                 @IPROUTE@ -o -6 route show | grep -v ' cache' | sed -E -e 's/ expires [0-9]*sec//' -e 's/ (mtu|hoplimit|cwnd|ssthresh) [0-9]+//g' -e 's/ (rtt|rttvar) [0-9]+ms//g'
             else
-	        echo "-- linux / ifconfig --"
-	        LANG=C @IFCONFIG@ -a |egrep  "( addr:|encap:)"
-	        LANG=C @NETSTAT@ -rn -4 -6
+                echo "-- linux / ifconfig --"
+                LANG=C @IFCONFIG@ -a | egrep "( addr:|encap:)"
+                LANG=C @NETSTAT@ -rn -4 -6
             fi
             ;;
-	FreeBSD|NetBSD|Darwin)
-	   echo "-- FreeBSD/NetBSD/Darwin [MacOS X] --"
-	   @IFCONFIG@ -a | egrep "(flags=|inet)"
-	   @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
-	   ;;
-	OpenBSD)
-	   echo "-- OpenBSD --"
-	   @IFCONFIG@ -a | egrep "(flags=|inet)" | \
-		sed -e 's/pltime [0-9]*//' -e 's/vltime [0-9]*//'
-	   @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
-	   ;;
-	SunOS)
-	   echo "-- Solaris --"
-	   @IFCONFIG@ -a | egrep "(flags=|inet)"
-	   @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
-	   ;;
-	AIX)
-	   echo "-- AIX --"
-	   @IFCONFIG@ -a | egrep "(flags=|inet)"
-	   @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
-	   ;;
+        FreeBSD | NetBSD | Darwin)
+            echo "-- FreeBSD/NetBSD/Darwin [MacOS X] --"
+            @IFCONFIG@ -a | egrep "(flags=|inet)"
+            @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
+            ;;
+        OpenBSD)
+            echo "-- OpenBSD --"
+            @IFCONFIG@ -a | egrep "(flags=|inet)" |
+                sed -e 's/pltime [0-9]*//' -e 's/vltime [0-9]*//'
+            @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
+            ;;
+        SunOS)
+            echo "-- Solaris --"
+            @IFCONFIG@ -a | egrep "(flags=|inet)"
+            @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
+            ;;
+        AIX)
+            echo "-- AIX --"
+            @IFCONFIG@ -a | egrep "(flags=|inet)"
+            @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
+            ;;
         *)
-           echo "get_ifconfig_route(): no idea how to get info on your OS (`uname -s`).  FAIL." >&2
-           exit 20
-           ;;
+            echo "get_ifconfig_route(): no idea how to get info on your OS ($(uname -s)).  FAIL." >&2
+            exit 20
+            ;;
     esac

     # another round of per-platform information gathering, for DNS info
     # for most of the platforms "cat /etc/resolv.conf" is good enough
     # except Linux and MacOS
     case $UNAME in
-	Linux)
-            if [ -x /usr/bin/resolvectl -a -d /run/systemd/system ] ; then
+        Linux)
+            if [ -x /usr/bin/resolvectl -a -d /run/systemd/system ]; then
                 echo "-- linux resolvectl --"
                 resolvectl status
             else
@@ -217,7 +217,7 @@
                 cat /etc/resolv.conf
             fi
             ;;
-	Darwin)
+        Darwin)
             echo "-- MacOS scutil --dns"
             scutil --dns
             ;;
@@ -234,19 +234,19 @@
 #  arg2: IPv4/IPv6 address that must show up in out of "get_ifconfig_route"
 check_ifconfig()
 {
-    proto=$1 ; shift
+    proto=$1
+    shift
     expect_list="$@"

-    if [ -z "$expect_list" ] ; then return ; fi
-    if [ "$expect_list" = "-" ] ; then return ; fi
+    if [ -z "$expect_list" ]; then return; fi
+    if [ "$expect_list" = "-" ]; then return; fi

-    for expect in $expect_list
-    do
-	if get_ifconfig_route | fgrep "$expect" >/dev/null
-	then :
-	else
-	    fail "check_ifconfig(): expected IPv$proto address '$expect' not found in ifconfig output."
-	fi
+    for expect in $expect_list; do
+        if get_ifconfig_route | fgrep "$expect" >/dev/null; then
+            :
+        else
+            fail "check_ifconfig(): expected IPv$proto address '$expect' not found in ifconfig output."
+        fi
     done
 }

@@ -257,47 +257,48 @@
 #  arg3... -> fping arguments (host list)
 run_ping_tests()
 {
-    proto=$1 ; want=$2 ; shift ; shift
+    proto=$1
+    want=$2
+    shift
+    shift
     targetlist="$@"

     # "no targets" is fine
-    if [ -z "$targetlist" ] ; then return ; fi
+    if [ -z "$targetlist" ]; then return; fi

     case $proto in
-	4) cmd="$FPING" ;;
-	6) cmd="$FPING6" ;;
-	*) echo "internal error in run_ping_tests arg 1: '$proto'" >&2
-	   exit 1 ;;
+        4) cmd="$FPING" ;;
+        6) cmd="$FPING6" ;;
+        *)
+            echo "internal error in run_ping_tests arg 1: '$proto'" >&2
+            exit 1
+            ;;
     esac

     case $want in
-	want_ok)   sizes_list="64 1440 3000" ;;
-	want_fail) sizes_list="64" ;;
+        want_ok) sizes_list="64 1440 3000" ;;
+        want_fail) sizes_list="64" ;;
     esac

-    for bytes in $sizes_list
-    do
-	output "run IPv$proto ping tests ($want), $bytes byte packets..."
+    for bytes in $sizes_list; do
+        output "run IPv$proto ping tests ($want), $bytes byte packets..."

-	echo "$cmd -b $bytes -C 20 -p 250 -q $fping_args $targetlist" >>$LOGDIR/$SUF:fping.out
-	$cmd -b $bytes -C 20 -p 250 -q $fping_args $targetlist >>$LOGDIR/$SUF:fping.out 2>&1
+        echo "$cmd -b $bytes -C 20 -p 250 -q $fping_args $targetlist" >>$LOGDIR/$SUF:fping.out
+        $cmd -b $bytes -C 20 -p 250 -q $fping_args $targetlist >>$LOGDIR/$SUF:fping.out 2>&1

-	# while OpenVPN is running, pings must succeed (want='want_ok')
-	# before OpenVPN is up, pings must NOT succeed (want='want_fail')
+        # while OpenVPN is running, pings must succeed (want='want_ok')
+        # before OpenVPN is up, pings must NOT succeed (want='want_fail')

-	rc=$?
-	if [ $rc = 0 ] 				# all ping OK
-	then
-	    if [ $want = "want_fail" ]		# not what we want
-	    then
-		fail "IPv$proto ping test succeeded, but needs to *fail*."
-	    fi
-	else					# ping failed
-	    if [ $want = "want_ok" ]		# not what we wanted
-	    then
-		fail "IPv$proto ping test ($bytes bytes) failed, but should succeed."
-	    fi
-	fi
+        rc=$?
+        if [ $rc = 0 ]; then                 # all ping OK
+            if [ $want = "want_fail" ]; then # not what we want
+                fail "IPv$proto ping test succeeded, but needs to *fail*."
+            fi
+        else                               # ping failed
+            if [ $want = "want_ok" ]; then # not what we wanted
+                fail "IPv$proto ping test ($bytes bytes) failed, but should succeed."
+            fi
+        fi
     done
 }

@@ -308,8 +309,7 @@
 SUMMARY_SKIP=
 SUMMARY_FAIL=

-for SUF in $TEST_RUN_LIST
-do
+for SUF in $TEST_RUN_LIST; do
     # get config variables
     eval test_prep=\"\$PREPARE_$SUF\"
     eval test_check_skip=\"\$CHECK_SKIP_$SUF\"
@@ -336,11 +336,13 @@

     if [ -n "$test_check_skip" ]; then
         output "check whether we need to skip: '$test_check_skip'"
-        if eval $test_check_skip; then :
+        if eval $test_check_skip; then
+            :
         else
             output "skip check failed, SKIP test $SUF."
-	    SUMMARY_SKIP="$SUMMARY_SKIP $SUF"
-	    printf "$outbuf" ; continue
+            SUMMARY_SKIP="$SUMMARY_SKIP $SUF"
+            printf "$outbuf"
+            continue
         fi
     fi

@@ -355,13 +357,14 @@
     output "\nrun pre-openvpn ping tests - targets must not be reachable..."
     run_ping_tests 4 want_fail "$ping4_hosts"
     run_ping_tests 6 want_fail "$ping6_hosts"
-    if [ "$fail_count" = 0 ] ; then
+    if [ "$fail_count" = 0 ]; then
         output "OK.\n"
     else
-	fail "make sure that ping hosts are ONLY reachable via VPN, SKIP test $SUF."
-	SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
-	exit_code=31
-	printf "$outbuf" ; continue
+        fail "make sure that ping hosts are ONLY reachable via VPN, SKIP test $SUF."
+        SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
+        exit_code=31
+        printf "$outbuf"
+        continue
     fi

     pidfile="$LOGDIR_ABS/openvpn-$SUF.pid"
@@ -376,18 +379,17 @@
     # to $ovpn_init_check times.
     ovpn_init_check=30
     ovpn_init_success=0
-    while [ $ovpn_init_check -gt 0 ];
-    do
-       sleep 1  # Wait for OpenVPN to initialize and have had time to write the pid file
-       grep "Initialization Sequence Completed" $LOGDIR/$SUF:openvpn.log >/dev/null
-       if [ $? -eq 0 ]; then
-           ovpn_init_check=0
-           ovpn_init_success=1
-       fi
-       ovpn_init_check=$(( $ovpn_init_check - 1 ))
+    while [ $ovpn_init_check -gt 0 ]; do
+        sleep 1 # Wait for OpenVPN to initialize and have had time to write the pid file
+        grep "Initialization Sequence Completed" $LOGDIR/$SUF:openvpn.log >/dev/null
+        if [ $? -eq 0 ]; then
+            ovpn_init_check=0
+            ovpn_init_success=1
+        fi
+        ovpn_init_check=$(($ovpn_init_check - 1))
     done

-    opid=`cat $pidfile`
+    opid=$(cat $pidfile)
     if [ -n "$opid" ]; then
         output "  OpenVPN running with PID $opid"
     else
@@ -398,16 +400,17 @@
     if [ $ovpn_init_success -ne 1 -o -z "$opid" ]; then
         output "$0:  OpenVPN did not initialize in a reasonable time"
         if [ -n "$opid" ]; then
-           $RUN_SUDO $KILL_EXEC $opid
+            $RUN_SUDO $KILL_EXEC $opid
         fi
         $RUN_SUDO $KILL_EXEC $sudopid
-	output "tail -5 $SUF:openvpn.log"
-	output "`tail -5 $LOGDIR/$SUF:openvpn.log`"
-	fail "skip rest of sub-tests for test run $SUF."
-	trap - 0 1 2 3 15
-	SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
-	exit_code=30
-	printf "$outbuf" ; continue
+        output "tail -5 $SUF:openvpn.log"
+        output "$(tail -5 $LOGDIR/$SUF:openvpn.log)"
+        fail "skip rest of sub-tests for test run $SUF."
+        trap - 0 1 2 3 15
+        SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
+        exit_code=30
+        printf "$outbuf"
+        continue
     fi

     # make sure openvpn client is terminated in case shell exits
@@ -418,17 +421,16 @@
     output "save ifconfig+route"
     get_ifconfig_route >$LOGDIR/$SUF:ifconfig_route.txt

-    if [ "$expect_ifconfig4" = "-" ] ; then
+    if [ "$expect_ifconfig4" = "-" ]; then
         output "skip ifconfig+route check"
     else
-	output -n "compare pre-openvpn ifconfig+route with current values..."
-	if diff $LOGDIR/$SUF:ifconfig_route_pre.txt \
-		$LOGDIR/$SUF:ifconfig_route.txt >/dev/null
-	then
-	    fail "no differences between ifconfig/route before OpenVPN start and now."
-	else
-	    output " OK!\n"
-	fi
+        output -n "compare pre-openvpn ifconfig+route with current values..."
+        if diff $LOGDIR/$SUF:ifconfig_route_pre.txt \
+            $LOGDIR/$SUF:ifconfig_route.txt >/dev/null; then
+            fail "no differences between ifconfig/route before OpenVPN start and now."
+        else
+            output " OK!\n"
+        fi
     fi

     # post init script needed?
@@ -449,8 +451,8 @@
     $RUN_SUDO $KILL_EXEC $opid
     wait $!
     rc=$?
-    if [ $rc != 0 ] ; then
-	fail "OpenVPN return code $rc, expect 0"
+    if [ $rc != 0 ]; then
+        fail "OpenVPN return code $rc, expect 0"
     fi

     output "\nsave post-openvpn ifconfig + route..."
@@ -458,23 +460,22 @@

     output -n "compare pre- and post-openvpn ifconfig + route..."
     if diff $LOGDIR/$SUF:ifconfig_route_pre.txt \
-	    $LOGDIR/$SUF:ifconfig_route_post.txt >$LOGDIR/$SUF:ifconfig_route_diff.txt
-    then
-	output " OK.\n"
+        $LOGDIR/$SUF:ifconfig_route_post.txt >$LOGDIR/$SUF:ifconfig_route_diff.txt; then
+        output " OK.\n"
     else
-	output "\n\n" "`cat $LOGDIR/$SUF:ifconfig_route_diff.txt`" "\n"
-	fail "differences between pre- and post-ifconfig/route."
+        output "\n\n" "$(cat $LOGDIR/$SUF:ifconfig_route_diff.txt)" "\n"
+        fail "differences between pre- and post-ifconfig/route."
     fi
-    if [ "$fail_count" = 0 ] ; then
+    if [ "$fail_count" = 0 ]; then
         output "test run $SUF: all tests OK.\n"
-	SUMMARY_OK="$SUMMARY_OK $SUF"
+        SUMMARY_OK="$SUMMARY_OK $SUF"
     else
-	if [ "$V" -gt 0 ] ; then
-	    printf "$outbuf"
-	    echo "test run $SUF: $fail_count test failures. FAIL."
+        if [ "$V" -gt 0 ]; then
+            printf "$outbuf"
+            echo "test run $SUF: $fail_count test failures. FAIL."
         fi
-	SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
-	exit_code=30
+        SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
+        exit_code=30
     fi

     if [ -n "$test_cleanup" ]; then
@@ -484,9 +485,9 @@

 done

-if [ -z "$SUMMARY_OK" ] ; then SUMMARY_OK=" none"; fi
-if [ -z "$SUMMARY_SKIP" ] ; then SUMMARY_SKIP=" none"; fi
-if [ -z "$SUMMARY_FAIL" ] ; then SUMMARY_FAIL=" none"; fi
+if [ -z "$SUMMARY_OK" ]; then SUMMARY_OK=" none"; fi
+if [ -z "$SUMMARY_SKIP" ]; then SUMMARY_SKIP=" none"; fi
+if [ -z "$SUMMARY_FAIL" ]; then SUMMARY_FAIL=" none"; fi
 echo "Test sets succeeded:$SUMMARY_OK."
 echo "Test sets skipped:$SUMMARY_SKIP."
 echo "Test sets failed:$SUMMARY_FAIL."
diff --git a/tests/t_cltsrv.sh b/tests/t_cltsrv.sh
index 6b7df65..03c3845 100755
--- a/tests/t_cltsrv.sh
+++ b/tests/t_cltsrv.sh
@@ -24,50 +24,58 @@
 trap "rm -f log.$$ log.$$.signal ; trap 0 ; exit 77" 1 2 15
 trap "rm -f log.$$ log.$$.signal ; exit 1" 0 3
 addopts=
-case `uname -s` in
+case $(uname -s) in
     FreeBSD)
-    # FreeBSD jails map the outgoing IP to the jail IP - we need to
-    # allow the real IP unless we want the test to run forever.
-    if test "`sysctl 2>/dev/null -n security.jail.jailed`" = 1 \
-    || ps -ostate= -p $$ | grep -q J; then
-	addopts="--float"
-	if test "x`ifconfig | grep inet`" = x ; then
-	    echo "###"
-	    echo "### To run the test in a FreeBSD jail, you MUST add an IP alias for the jail's IP."
-	    echo "###"
-	    exit 77
-	fi
-    fi
-    ;;
+        # FreeBSD jails map the outgoing IP to the jail IP - we need to
+        # allow the real IP unless we want the test to run forever.
+        if test "$(sysctl 2>/dev/null -n security.jail.jailed)" = 1 ||
+            ps -ostate= -p $$ | grep -q J; then
+            addopts="--float"
+            if test "x$(ifconfig | grep inet)" = x; then
+                echo "###"
+                echo "### To run the test in a FreeBSD jail, you MUST add an IP alias for the jail's IP."
+                echo "###"
+                exit 77
+            fi
+        fi
+        ;;
 esac

 # make sure that the --down script is executable -- fail (rather than
 # skip) test if it isn't.
 downscript="../tests/t_cltsrv-down.sh"
 root="${top_srcdir}/sample"
-test -x "${root}/${downscript}" || chmod +x "${root}/${downscript}" || { echo >&2 "${root}/${downscript} is not executable, failing." ; exit 1 ; }
+test -x "${root}/${downscript}" || chmod +x "${root}/${downscript}" || {
+    echo >&2 "${root}/${downscript} is not executable, failing."
+    exit 1
+}
 echo "The following test will take about two minutes." >&2
 echo "If the addresses are in use, this test will retry up to two times." >&2

 # go
 success=0
-for i in 1 2 3 ; do
-  set +e
-  (
-  "${openvpn}" --script-security 2 --cd "${root}" ${addopts} --setenv role srv --down "${downscript}" --tls-exit --ping-exit 180 --config "sample-config-files/loopback-server" &
-  "${openvpn}" --script-security 2 --cd "${top_srcdir}/sample" ${addopts} --setenv role clt --down "${downscript}" --tls-exit --ping-exit 180 --config "sample-config-files/loopback-client"
-  ) 3>log.$$.signal >log.$$ 2>&1
-  e1=$?
-  wait $!
-  e2=$?
-  grep 'TCP/UDP: Socket bind failed on local address.*in use' log.$$ >/dev/null && {
-    echo 'address in use, retrying in 150 s'
-    sleep 150
-    continue
-  }
-  grep -v ':inactive$' log.$$.signal >/dev/null && { cat log.$$.signal ; echo ; cat log.$$ ; exit 1 ; }
-  success=1
-  break
+for i in 1 2 3; do
+    set +e
+    (
+        "${openvpn}" --script-security 2 --cd "${root}" ${addopts} --setenv role srv --down "${downscript}" --tls-exit --ping-exit 180 --config "sample-config-files/loopback-server" &
+        "${openvpn}" --script-security 2 --cd "${top_srcdir}/sample" ${addopts} --setenv role clt --down "${downscript}" --tls-exit --ping-exit 180 --config "sample-config-files/loopback-client"
+    ) 3>log.$$.signal >log.$$ 2>&1
+    e1=$?
+    wait $!
+    e2=$?
+    grep 'TCP/UDP: Socket bind failed on local address.*in use' log.$$ >/dev/null && {
+        echo 'address in use, retrying in 150 s'
+        sleep 150
+        continue
+    }
+    grep -v ':inactive$' log.$$.signal >/dev/null && {
+        cat log.$$.signal
+        echo
+        cat log.$$
+        exit 1
+    }
+    success=1
+    break
 done

 set -e
@@ -75,14 +83,14 @@
 # exit code - defaults to 0, PASS
 ec=0

-if [ $success != 1 ] ; then
-  # couldn't run test -- addresses in use, skip test
-  cat log.$$
-  ec=77
-elif [ $e1 != 0 ] || [ $e2 != 0 ] ; then
-  # failure -- fail test
-  cat log.$$
-  ec=1
+if [ $success != 1 ]; then
+    # couldn't run test -- addresses in use, skip test
+    cat log.$$
+    ec=77
+elif [ $e1 != 0 ] || [ $e2 != 0 ]; then
+    # failure -- fail test
+    cat log.$$
+    ec=1
 fi

 rm log.$$ log.$$.signal
diff --git a/tests/t_lpback.sh b/tests/t_lpback.sh
index 6802506..058206f 100755
--- a/tests/t_lpback.sh
+++ b/tests/t_lpback.sh
@@ -37,51 +37,56 @@
 test_start()
 {
     case $V in
-        0) outbuf="" ;;                  # no per-test output at all
-        1) outbuf="$@" ;;                # compact, details only on failure
-        *) printf "$@" ;;                # print all
+        0) outbuf="" ;;   # no per-test output at all
+        1) outbuf="$@" ;; # compact, details only on failure
+        *) printf "$@" ;; # print all
     esac
 }
 test_end()
 {
-    RC=$1 ; LOG=$2
-    if [ $RC != 0 ]
-    then
+    RC=$1
+    LOG=$2
+    if [ $RC != 0 ]; then
         case $V in
-            0) ;;                                # no per-test output
-            1) echo "$outbuf" "FAIL (RC=$RC)"; cat $LOG ;;
-            *) echo "FAIL (RC=$RC)"; cat $LOG ;;
+            0) ;; # no per-test output
+            1)
+                echo "$outbuf" "FAIL (RC=$RC)"
+                cat $LOG
+                ;;
+            *)
+                echo "FAIL (RC=$RC)"
+                cat $LOG
+                ;;
         esac
         e=1
-        tests_failed=$(( $tests_failed + 1 ))
+        tests_failed=$(($tests_failed + 1))
     else
         case $V in
-            0|1) ;;                              # no per-test output for 'OK'
-            *) echo "OK"                         # print all
+            0 | 1) ;;       # no per-test output for 'OK'
+            *) echo "OK" ;; # print all
         esac
-        tests_passed=$(( $tests_passed + 1 ))
+        tests_passed=$(($tests_passed + 1))
     fi
 }

 # if running with V=1, give an indication what test runs now
-if [ "$V" = 1  ] ; then
+if [ "$V" = 1 ]; then
     echo "$0: running with V=$V, only printing test fails"
 fi

-
 # Get list of supported ciphers from openvpn --show-ciphers output
-CIPHERS=$(${openvpn} --show-ciphers | \
-            sed -e '/The following/,/^$/d' -e s'/ .*//' -e '/^[[:space:]]*$/d')
+CIPHERS=$(${openvpn} --show-ciphers |
+    sed -e '/The following/,/^$/d' -e s'/ .*//' -e '/^[[:space:]]*$/d')

 # SK, 2014-06-04: currently the DES-EDE3-CFB1 implementation of OpenSSL is
 # broken (see http://rt.openssl.org/Ticket/Display.html?id=2867), so exclude
 # that cipher from this test.
 # GD, 2014-07-06 so is DES-CFB1
 # GD, 2014-07-06 do not test RC5-* either (fails on NetBSD w/o libcrypto_rc5)
-CIPHERS=$(echo "$CIPHERS" | egrep -v '^(DES-EDE3-CFB1|DES-CFB1|RC5-)' )
+CIPHERS=$(echo "$CIPHERS" | egrep -v '^(DES-EDE3-CFB1|DES-CFB1|RC5-)')

 e=0
-if [ -z "$CIPHERS" ] ; then
+if [ -z "$CIPHERS" ]; then
     echo "'openvpn --show-ciphers' FAILED (empty list)"
     e=1
 fi
@@ -91,10 +96,9 @@
 
 set +e

-for cipher in ${CIPHERS}
-do
+for cipher in ${CIPHERS}; do
     test_start "Testing cipher ${cipher}... "
-    ( "${openvpn}" --test-crypto --cipher ${cipher} ) >log.$$ 2>&1
+    ("${openvpn}" --test-crypto --cipher ${cipher}) >log.$$ 2>&1
     test_end $? log.$$
 done

@@ -121,7 +125,7 @@
     >log.$$ 2>&1
 test_end $? log.$$

-if [ "$V" -ge 1  ] ; then
+if [ "$V" -ge 1 ]; then
     echo "$0: tests passed: $tests_passed  failed: $tests_failed"
 fi

diff --git a/tests/t_net.sh b/tests/t_net.sh
index 8134832..17e028e 100755
--- a/tests/t_net.sh
+++ b/tests/t_net.sh
@@ -9,7 +9,6 @@
 top_builddir="${top_builddir:-..}"
 openvpn="${openvpn:-${top_builddir}/src/openvpn/openvpn}"

-
 # bail out right away on non-linux. NetLink (the object of this test) is only
 # used on Linux, therefore testing other platform is not needed.
 #
@@ -69,7 +68,6 @@
     done
 }

-
 ## execution starts here

 # t_client.rc required only for RUN_SUDO definition
@@ -89,21 +87,18 @@
     exit 77
 fi

-
 # Ensure PREFER_KSU is in a known state
 PREFER_KSU="${PREFER_KSU:-0}"

 # make sure we have permissions to run the networking unit-test
-ID=`id`
-if expr "$ID" : "uid=0" >/dev/null
-then :
+ID=$(id)
+if expr "$ID" : "uid=0" >/dev/null; then
+    :
 else
-    if [ "${PREFER_KSU}" -eq 1 ];
-    then
+    if [ "${PREFER_KSU}" -eq 1 ]; then
         # Check if we have a valid kerberos ticket
         klist -l 1>/dev/null 2>/dev/null
-        if [ $? -ne 0 ];
-        then
+        if [ $? -ne 0 ]; then
             # No kerberos ticket found, skip ksu and fallback to RUN_SUDO
             PREFER_KSU=0
             echo "$0: No Kerberos ticket available.  Will not use ksu."
@@ -112,16 +107,14 @@
         fi
     fi

-    if [ -z "$RUN_SUDO" ]
-    then
+    if [ -z "$RUN_SUDO" ]; then
         echo "$0: no RUN_SUDO=... in t_client.rc or environment, defaulting to 'sudo'." >&2
         echo "      if that does not work, set RUN_SUDO= correctly for your system." >&2
         RUN_SUDO="sudo"
     fi

     # check that we can run the unit-test binary with sudo
-    if $RUN_SUDO $UNIT_TEST test
-    then
+    if $RUN_SUDO $UNIT_TEST test; then
         echo "$0: $RUN_SUDO $UNIT_TEST succeeded, good."
     else
         echo "$0: $RUN_SUDO $UNIT_TEST failed, cannot go on. SKIP." >&2
diff --git a/tests/t_server_null.sh b/tests/t_server_null.sh
index 74ffd52..c633614 100755
--- a/tests/t_server_null.sh
+++ b/tests/t_server_null.sh
@@ -2,7 +2,7 @@
 #
 TSERVER_NULL_SKIP_RC="${TSERVER_NULL_SKIP_RC:-77}"

-if ! [ -r "./t_server_null.rc" ] ; then
+if ! [ -r "./t_server_null.rc" ]; then
     echo "${0}: cannot find './t_server_null.rc. SKIPPING TEST.'" >&2
     exit "${TSERVER_NULL_SKIP_RC}"
 fi
@@ -22,11 +22,10 @@
 # make sure we have permissions to run ifconfig/route from OpenVPN
 # can't use "id -u" here - doesn't work on Solaris
 ID=$(id)
-if expr "$ID" : "uid=0" >/dev/null
-then :
+if expr "$ID" : "uid=0" >/dev/null; then
+    :
 else
-    if [ "${PREFER_KSU}" -eq 1 ];
-    then
+    if [ "${PREFER_KSU}" -eq 1 ]; then
         # Check if we have a valid kerberos ticket
         if klist -l 1>/dev/null 2>/dev/null; then
             RUN_SUDO="ksu -q -e"
@@ -37,26 +36,24 @@
         fi
     fi

-    if [ -z "$RUN_SUDO" ]
-    then
+    if [ -z "$RUN_SUDO" ]; then
         echo "${0}: this test must run be as root, or RUN_SUDO=... " >&2
         echo "      must be set correctly in 't_server_null.rc'. SKIP." >&2
         exit "${TSERVER_NULL_SKIP_RC}"
     else
-	# Run a no-op command with privilege escalation (e.g. sudo) so that
-	# we (hopefully) do not have to ask the users password during the test.
-	if $RUN_SUDO "${KILL_EXEC}" -0 $$
-	then
-	    echo "${0}: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
-	else
-	    echo "${0}: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
-	    exit "${TSERVER_NULL_SKIP_RC}"
-	fi
+        # Run a no-op command with privilege escalation (e.g. sudo) so that
+        # we (hopefully) do not have to ask the users password during the test.
+        if $RUN_SUDO "${KILL_EXEC}" -0 $$; then
+            echo "${0}: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
+        else
+            echo "${0}: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
+            exit "${TSERVER_NULL_SKIP_RC}"
+        fi
     fi
 fi

 srcdir="${srcdir:-.}"
-export t_server_null_logdir=t_server_null-`hostname`-`date +%Y%m%d-%H%M%S`
+export t_server_null_logdir=t_server_null-$(hostname)-$(date +%Y%m%d-%H%M%S)

 # Create directory for server and client logs
 mkdir $t_server_null_logdir
diff --git a/tests/t_server_null_client.sh b/tests/t_server_null_client.sh
index 1745de5..3203cc2 100755
--- a/tests/t_server_null_client.sh
+++ b/tests/t_server_null_client.sh
@@ -1,9 +1,10 @@
 #!/bin/sh

-should_run_test() {
+should_run_test()
+{
     test_name="$1"

-    if echo "$test_name"|grep -q _lwip; then
+    if echo "$test_name" | grep -q _lwip; then
         if [ "$has_lwipovpn" = "no" ]; then
             return 1
         fi
@@ -12,7 +13,8 @@
     return 0
 }

-launch_client() {
+launch_client()
+{
     test_name=$1
     log="${test_name}.log"
     pid="${test_name}.pid"
@@ -30,7 +32,8 @@
         --log "${t_server_null_logdir}/${log}" &
 }

-ping_and_kill() {
+ping_and_kill()
+{
     if fping -q -c 5 $1; then
         echo "PASS: fping lwipovpn client $target"
     else
@@ -46,9 +49,10 @@
     kill -15 $2
 }

-ping_lwip_clients() {
+ping_lwip_clients()
+{
     if [ "$has_lwipovpn" = "yes" ]; then
-        lwip_client_count=$(echo "$lwip_test_names"|wc -w|tr -d " ")
+        lwip_client_count=$(echo "$lwip_test_names" | wc -w | tr -d " ")
     else
         lwip_client_count=0
     fi
@@ -60,10 +64,10 @@
     count=0
     maxcount=10
     while [ $count -le $maxcount ]; do
-        lwip_client_ips=$(cat ./*.lwip 2>/dev/null|wc -l)
+        lwip_client_ips=$(cat ./*.lwip 2>/dev/null | wc -l)
         if [ $lwip_client_ips -lt $lwip_client_count ]; then
             echo "Waiting for LWIP clients to start up ($count/$maxcount)"
-            count=$(( count + 1))
+            count=$((count + 1))
             sleep 1
         else
             echo "$lwip_client_ips/$lwip_client_count LWIP clients up"
@@ -73,8 +77,8 @@

     wait_pids=""
     for line in $(cat ./*.lwip 2>/dev/null); do
-        target_ip=$(echo $line|cut -d "," -f 1)
-        client_pid=$(echo $line|cut -d "," -f 2)
+        target_ip=$(echo $line | cut -d "," -f 1)
+        client_pid=$(echo $line | cut -d "," -f 2)
         ping_and_kill $target_ip $client_pid &
         wait_pids="$wait_pids $!"
     done
@@ -84,7 +88,8 @@
     test -e ./lwip_failed && return 1 || return 0
 }

-wait_for_results() {
+wait_for_results()
+{
     tests_running="yes"

     # Wait a bit to allow an OpenVPN client process to create a pidfile to
@@ -106,12 +111,13 @@
     done
 }

-get_client_test_result() {
+get_client_test_result()
+{
     test_name=$1
     should_pass=$2
     log="${test_name}.log"

-    grep "Initialization Sequence Completed" "${t_server_null_logdir}/${log}" > /dev/null
+    grep "Initialization Sequence Completed" "${t_server_null_logdir}/${log}" >/dev/null
     exit_code=$?

     if [ $exit_code -eq 0 ] && [ "${should_pass}" = "yes" ]; then
@@ -144,7 +150,7 @@
 server_max_wait=15
 while [ $count -lt $server_max_wait ]; do
     servers_up=0
-    server_count=$(echo "$TEST_SERVER_LIST"|wc -w|tr -d " ")
+    server_count=$(echo "$TEST_SERVER_LIST" | wc -w | tr -d " ")

     # We need to trim single-quotes because some shells return quoted values
     # and some don't. Using "set -o posix" which would resolve this problem is
@@ -152,13 +158,13 @@
     #
     # While inactive server configurations may get checked they won't increase
     # the active server count as the processes won't be running.
-    for i in $(set|grep 'SERVER_NAME_'|cut -d "=" -f 2|tr -d "[\']"); do
-        server_pid=$(cat "$i.pid" 2> /dev/null)
-        if [ -z "$server_pid" ] ; then
+    for i in $(set | grep 'SERVER_NAME_' | cut -d "=" -f 2 | tr -d "[\']"); do
+        server_pid=$(cat "$i.pid" 2>/dev/null)
+        if [ -z "$server_pid" ]; then
             continue
         fi
-        if $RUN_SUDO kill -0 $server_pid > /dev/null 2>&1; then
-            servers_up=$(( $servers_up + 1 ))
+        if $RUN_SUDO kill -0 $server_pid >/dev/null 2>&1; then
+            servers_up=$(($servers_up + 1))
         fi
     done

@@ -168,7 +174,7 @@
         retval=0
         break
     else
-        count=$(( count + 1))
+        count=$((count + 1))
         sleep 1
     fi

@@ -199,15 +205,14 @@
 # safe to check the test results.
 test_names=""
 lwip_test_names=""
-for SUF in $TEST_RUN_LIST
-do
+for SUF in $TEST_RUN_LIST; do
     eval test_name=\"\$TEST_NAME_$SUF\"
     eval client_exec=\"\$CLIENT_EXEC_$SUF\"
     eval client_conf=\"\$CLIENT_CONF_$SUF\"

     test_names="${test_names} ${test_name}"

-    if echo "$test_name"|grep -q _lwip; then
+    if echo "$test_name" | grep -q _lwip; then
         lwip_test_names="${lwip_test_names} ${test_name}"
     fi

@@ -219,13 +224,11 @@
 ping_lwip_clients
 retval=$?

-
 # Wait until all OpenVPN clients have exited
 (wait_for_results)

 # Check test results
-for SUF in $TEST_RUN_LIST
-do
+for SUF in $TEST_RUN_LIST; do
     eval test_name=\"\$TEST_NAME_$SUF\"
     eval should_pass=\"\$SHOULD_PASS_$SUF\"

diff --git a/tests/t_server_null_server.sh b/tests/t_server_null_server.sh
index e1775f0..a8d7268 100755
--- a/tests/t_server_null_server.sh
+++ b/tests/t_server_null_server.sh
@@ -1,6 +1,7 @@
 #!/bin/sh

-launch_server() {
+launch_server()
+{
     server_name=$1
     server_exec=$2
     server_conf=$3
@@ -17,10 +18,10 @@

     # Try to launch the server
     $RUN_SUDO "${server_exec}" \
-               $server_conf \
-               --status "${status}" 1 \
-               --writepid "${pid}" \
-               --explicit-exit-notify 3 > "$log" 2>&1 &
+        $server_conf \
+        --status "${status}" 1 \
+        --writepid "${pid}" \
+        --explicit-exit-notify 3 >"$log" 2>&1 &

     sleep 1

@@ -44,8 +45,7 @@
 retval=0

 # Launch test servers
-for SUF in $TEST_SERVER_LIST
-do
+for SUF in $TEST_SERVER_LIST; do
     eval server_name=\"\$SERVER_NAME_$SUF\"
     eval server_exec=\"\$SERVER_EXEC_$SUF\"
     eval server_conf=\"\$SERVER_CONF_$SUF\"
@@ -57,8 +57,7 @@
 # the test run.
 #
 export server_pid_files=""
-for SUF in $TEST_SERVER_LIST
-do
+for SUF in $TEST_SERVER_LIST; do
     eval server_name=\"\$SERVER_NAME_$SUF\"
     server_pid_files="${server_pid_files} ./${server_name}.pid"
 done
@@ -69,12 +68,11 @@
 count=0
 maxcount=4
 while [ $count -le $maxcount ]; do
-    if ls t_server_null_client.sh*.pid > /dev/null 2>&1
-    then
+    if ls t_server_null_client.sh*.pid >/dev/null 2>&1; then
         count=0
         sleep 1
     else
-	count=$(( count + 1))
+        count=$((count + 1))
         sleep 1
     fi
 done
@@ -85,11 +83,10 @@
 # server process does not exit in 15 seconds assume it never will, move on and
 # hope for the best.
 echo "Waiting for servers to exit"
-for PID_FILE in $server_pid_files
-do
+for PID_FILE in $server_pid_files; do
     SERVER_PID=$(cat "${PID_FILE}")

-    if [ -z "$SERVER_PID" ] ; then
+    if [ -z "$SERVER_PID" ]; then
         echo "WARNING: could not kill server ${PID_FILE}!"
         continue
     fi
@@ -99,17 +96,16 @@

     count=0
     maxcount=75
-    while [ $count -le $maxcount ]
-    do
-        $RUN_SUDO kill -0 "${SERVER_PID}" 2> /dev/null || break
-        count=$(( count + 1))
+    while [ $count -le $maxcount ]; do
+        $RUN_SUDO kill -0 "${SERVER_PID}" 2>/dev/null || break
+        count=$((count + 1))
         sleep 0.2
     done

     # If server is still up send a SIGKILL
     if [ $count -ge $maxcount ]; then
         $RUN_SUDO $KILL_EXEC -9 "${SERVER_PID}"
-        SERVER_NAME=$(basename $PID_FILE|cut -d . -f 1)
+        SERVER_NAME=$(basename $PID_FILE | cut -d . -f 1)
         echo "ERROR: had to send SIGKILL to server ${SERVER_NAME} with pid ${SERVER_PID}!"
         echo "Tail of server log:"
         tail -n 20 "${t_server_null_logdir}/${SERVER_NAME}.log"
diff --git a/tests/t_server_null_stress.sh b/tests/t_server_null_stress.sh
index 0bb9452..2fc9fde 100755
--- a/tests/t_server_null_stress.sh
+++ b/tests/t_server_null_stress.sh
@@ -7,8 +7,7 @@
 . ./t_server_null_default.rc

 export pid_files=""
-for SUF in $TEST_SERVER_LIST
-do
+for SUF in $TEST_SERVER_LIST; do
     eval server_name=\"\$SERVER_NAME_$SUF\"
     pid_files="${pid_files} ./${server_name}.pid"
 done
@@ -18,16 +17,16 @@

 count=0
 while [ $count -lt $ITERATIONS ]; do
-    count=$(( count + 1 ))
-    make check TESTS=t_server_null.sh SUBDIRS= > /dev/null 2>&1
+    count=$((count + 1))
+    make check TESTS=t_server_null.sh SUBDIRS= >/dev/null 2>&1
     retval=$?

-    echo "Iteration ${count}: return value ${retval}" >> "${LOG_BASEDIR}/make-check.log"
+    echo "Iteration ${count}: return value ${retval}" >>"${LOG_BASEDIR}/make-check.log"
     if [ $retval -ne 0 ]; then
-	DIR="${LOG_BASEDIR}/make-check-${count}"
+        DIR="${LOG_BASEDIR}/make-check-${count}"
         mkdir -p "${DIR}"
         cp t_server_null*.log "${DIR}/"
         cp test-suite.log "${DIR}/"
-        ps aux|grep openvpn|grep -vE '(suppress|grep)' > "${DIR}/psaux"
+        ps aux | grep openvpn | grep -vE '(suppress|grep)' >"${DIR}/psaux"
     fi
 done
diff --git a/tests/update_t_client_ips.sh b/tests/update_t_client_ips.sh
index 96e3826..777a286 100755
--- a/tests/update_t_client_ips.sh
+++ b/tests/update_t_client_ips.sh
@@ -5,12 +5,12 @@

 RC="$TOP_BUILDDIR/t_client_ips.rc"

-grep EXPECT_IFCONFIG4_$TESTNUM= $RC > /dev/null 2>&1
+grep EXPECT_IFCONFIG4_$TESTNUM= $RC >/dev/null 2>&1
 if [ $? -ne 0 ]; then
-    echo "EXPECT_IFCONFIG4_$TESTNUM=$ifconfig_local" >> $RC
+    echo "EXPECT_IFCONFIG4_$TESTNUM=$ifconfig_local" >>$RC
 fi

-grep EXPECT_IFCONFIG6_$TESTNUM= $RC > /dev/null 2>&1
+grep EXPECT_IFCONFIG6_$TESTNUM= $RC >/dev/null 2>&1
 if [ $? -ne 0 ]; then
-    echo "EXPECT_IFCONFIG6_$TESTNUM=$ifconfig_ipv6_local" >> $RC
+    echo "EXPECT_IFCONFIG6_$TESTNUM=$ifconfig_ipv6_local" >>$RC
 fi

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1793?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f
Gerrit-Change-Number: 1793
Gerrit-PatchSet: 4
Gerrit-Owner: flichtenheld <frank@lichtenheld.com>
Gerrit-Reviewer: plaisthos <arne-openvpn@rfc2549.org>
Gerrit-Reviewer: razvanc <razvanc@mailbox.org>
Gerrit-CC: openvpn-devel <openvpn-devel@lists.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@rfc2549.org>
Gerrit-Attention: flichtenheld <frank@lichtenheld.com>
Gerrit-Attention: razvanc <razvanc@mailbox.org>

[-- Attachment #1.2: Type: text/html, Size: 110326 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Openvpn-devel] [L] Change in openvpn[master]: Reformat all shell-scripts with shfmt
       [not found] <gerrit.1784305303000.I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f@gerrit.openvpn.net>
                   ` (7 preceding siblings ...)
  2026-08-19 13:18 ` flichtenheld (Code Review) via Openvpn-devel
@ 2026-08-19 13:44 ` razvanc (Code Review) via Openvpn-devel
  2026-08-20  9:15 ` [Openvpn-devel] [PATCH v4] " Gert Doering
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: razvanc (Code Review) via Openvpn-devel @ 2026-08-19 13:44 UTC (permalink / raw)
  To: flichtenheld; +Cc: razvanc (Code Review), openvpn-devel, plaisthos


[-- Attachment #1.1: Type: text/plain, Size: 1145 bytes --]

Attention is currently required from: flichtenheld, plaisthos.

razvanc has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1793?usp=email )

Change subject: Reformat all shell-scripts with shfmt
......................................................................


Patch Set 4: Code-Review+2


--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1793?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f
Gerrit-Change-Number: 1793
Gerrit-PatchSet: 4
Gerrit-Owner: flichtenheld <frank@lichtenheld.com>
Gerrit-Reviewer: plaisthos <arne-openvpn@rfc2549.org>
Gerrit-Reviewer: razvanc <razvanc@mailbox.org>
Gerrit-CC: openvpn-devel <openvpn-devel@lists.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@rfc2549.org>
Gerrit-Attention: flichtenheld <frank@lichtenheld.com>
Gerrit-Comment-Date: Wed, 19 Aug 2026 13:44:54 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

[-- Attachment #1.2: Type: text/html, Size: 2092 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Openvpn-devel] [PATCH v4] Reformat all shell-scripts with shfmt
       [not found] <gerrit.1784305303000.I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f@gerrit.openvpn.net>
                   ` (8 preceding siblings ...)
  2026-08-19 13:44 ` razvanc (Code Review) via Openvpn-devel
@ 2026-08-20  9:15 ` Gert Doering
  2026-08-20 10:36   ` [Openvpn-devel] [PATCH applied] " Gert Doering
  2026-08-20 10:36 ` [Openvpn-devel] [L] Change in openvpn[master]: " cron2 (Code Review) via Openvpn-devel
  2026-08-20 10:36 ` cron2 (Code Review) via Openvpn-devel
  11 siblings, 1 reply; 13+ messages in thread
From: Gert Doering @ 2026-08-20  9:15 UTC (permalink / raw)
  To: openvpn-devel

From: Frank Lichtenheld <frank@lichtenheld.com>

According to ./dev-tools/reformat-shell.sh.

Change-Id: I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Razvan Cojocaru <razvanc@mailbox.org>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1793
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1793
This mail reflects revision 4 of this Change.

Acked-by according to Gerrit (reflected above):
Razvan Cojocaru <razvanc@mailbox.org>

        
diff --git a/dev-tools/git-pre-commit-format.sh b/dev-tools/git-pre-commit-format.sh
index 9b2ecaf..3507289 100755
--- a/dev-tools/git-pre-commit-format.sh
+++ b/dev-tools/git-pre-commit-format.sh
@@ -26,7 +26,6 @@
 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-
 # git pre-commit hook that runs a stylecheck.
 # Features:
 #  - abort commit when commit does not comply with the style guidelines
@@ -43,12 +42,11 @@
 # exit on error
 set -e
 
-
 # If called so, install this script as pre-commit hook
-if [ "$1" = "install" ] ; then
+if [ "$1" = "install" ]; then
     TARGET="$(git rev-parse --git-path hooks)/pre-commit"
 
-    if [ -e "$TARGET" ] ; then
+    if [ -e "$TARGET" ]; then
         printf "$TARGET file exists. Won't overwrite.\n"
         printf "Aborting installation.\n"
         exit 1
@@ -62,18 +60,19 @@
 fi
 
 # check whether the given file matches any of the set extensions
-matches_extension() {
+matches_extension()
+{
     local filename="$(basename -- "$1")"
     local extension=".${filename##*.}"
     local ext
 
-    for ext in .c .h ; do [ "$ext" = "$extension" ] && return 0; done
+    for ext in .c .h; do [ "$ext" = "$extension" ] && return 0; done
 
     return 1
 }
 
 # necessary check for initial commit
-if git rev-parse --verify HEAD >/dev/null 2>&1 ; then
+if git rev-parse --verify HEAD >/dev/null 2>&1; then
     against=HEAD
 else
     # Initial commit: diff against an empty tree object
@@ -88,8 +87,8 @@
 
     # Allow to use in parallel with pre-commit
     if [ $(basename "$0") = "pre-commit.legacy" ]; then
-       echo "Skipping clang-format check in favor of pre-commit"
-       exit 0
+        echo "Skipping clang-format check in favor of pre-commit"
+        exit 0
     fi
 else
     TOOL=uncrustify
@@ -98,7 +97,7 @@
     TOOL_CMD="$TOOL_BIN -q -l C -c $UNCRUST_CONFIG"
 
     # make sure the config file is correctly set
-    if [ ! -f "$UNCRUST_CONFIG" ] ; then
+    if [ ! -f "$UNCRUST_CONFIG" ]; then
         printf "Error: uncrustify config file not found.\n"
         printf "Expected to find it at $UNCRUST_CONFIG.\n"
         printf "Aborting commit.\n"
@@ -106,7 +105,7 @@
     fi
 fi
 
-if [ -z "$TOOL_BIN" ] ; then
+if [ -z "$TOOL_BIN" ]; then
     printf "Error: $TOOL executable not found.\n"
     printf "Is it installed and in your \$PATH?\n"
     printf "Aborting commit.\n"
@@ -120,44 +119,43 @@
 # create one patch containing all changes to the files
 # sed to remove quotes around the filename, if inserted by the system
 # (done sometimes, if the filename contains special characters, like the quote itself)
-git diff-index --cached --diff-filter=ACMR --name-only $against -- | \
-sed -e 's/^"\(.*\)"$/\1/' | \
-while read file
-do
-    # ignore file if we do check for file extensions and the file
-    # does not match the extensions .c or .h
-    if ! matches_extension "$file"; then
-        continue;
-    fi
+git diff-index --cached --diff-filter=ACMR --name-only $against -- |
+    sed -e 's/^"\(.*\)"$/\1/' |
+    while read file; do
+        # ignore file if we do check for file extensions and the file
+        # does not match the extensions .c or .h
+        if ! matches_extension "$file"; then
+            continue
+        fi
 
-    # escape special characters in the target filename:
-    # phase 1 (characters escaped in the output diff):
-    #     - '\': backslash needs to be escaped in the output diff
-    #     - '"': quote needs to be escaped in the output diff if present inside
-    #            of the filename, as it used to bracket the entire filename part
-    # phase 2 (characters escaped in the match replacement):
-    #     - '\': backslash needs to be escaped again for sed itself
-    #            (i.e. double escaping after phase 1)
-    #     - '&': would expand to matched string
-    #     - '|': used as sed split char instead of '/'
-    # printf %s particularly important if the filename contains the % character
-    file_escaped_target=$(printf "%s" "$file" | sed -e 's/[\"]/\\&/g' -e 's/[\&|]/\\&/g')
+        # escape special characters in the target filename:
+        # phase 1 (characters escaped in the output diff):
+        #     - '\': backslash needs to be escaped in the output diff
+        #     - '"': quote needs to be escaped in the output diff if present inside
+        #            of the filename, as it used to bracket the entire filename part
+        # phase 2 (characters escaped in the match replacement):
+        #     - '\': backslash needs to be escaped again for sed itself
+        #            (i.e. double escaping after phase 1)
+        #     - '&': would expand to matched string
+        #     - '|': used as sed split char instead of '/'
+        # printf %s particularly important if the filename contains the % character
+        file_escaped_target=$(printf "%s" "$file" | sed -e 's/[\"]/\\&/g' -e 's/[\&|]/\\&/g')
 
-    # uncrustify our sourcefile, create a patch with diff and append it to our $patch
-    # The sed call is necessary to transform the patch from
-    #    --- - timestamp
-    #    +++ $tmpout timestamp
-    # to both lines working on the same file and having a a/ and b/ prefix.
-    # Else it can not be applied with 'git apply'.
-    git show ":$file" | $TOOL_CMD > "$tmpout"
-    git show ":$file" | diff -u -- - "$tmpout" | \
-        sed -e "1s|--- -|--- \"b/$file_escaped_target\"|" -e "2s|+++ $tmpout|+++ \"a/$file_escaped_target\"|" >> "$patch"
-done
+        # uncrustify our sourcefile, create a patch with diff and append it to our $patch
+        # The sed call is necessary to transform the patch from
+        #    --- - timestamp
+        #    +++ $tmpout timestamp
+        # to both lines working on the same file and having a a/ and b/ prefix.
+        # Else it can not be applied with 'git apply'.
+        git show ":$file" | $TOOL_CMD >"$tmpout"
+        git show ":$file" | diff -u -- - "$tmpout" |
+            sed -e "1s|--- -|--- \"b/$file_escaped_target\"|" -e "2s|+++ $tmpout|+++ \"a/$file_escaped_target\"|" >>"$patch"
+    done
 
 rm -f "$tmpout"
 
 # if no patch has been generated all is ok, clean up the file stub and exit
-if [ ! -s "$patch" ] ; then
+if [ ! -s "$patch" ]; then
     rm -f "$patch"
     exit 0
 fi
@@ -165,7 +163,7 @@
 # a patch has been created, notify the user and exit
 printf "Formatting of some code does not follow the project guidelines.\n"
 
-if [ $(wc -l < $patch) -gt 80 ] ; then
+if [ $(wc -l <$patch) -gt 80 ]; then
     printf "The file $patch contains the necessary fixes.\n"
 else
     printf "Here's the patch that fixes the formatting:\n\n"
diff --git a/dev-tools/run-cppcheck.sh b/dev-tools/run-cppcheck.sh
index 40db33e..a7aa3c4 100755
--- a/dev-tools/run-cppcheck.sh
+++ b/dev-tools/run-cppcheck.sh
@@ -20,24 +20,23 @@
  --check-level=exhaustive --max-configs=10 \
  --error-exitcode=1"
 
-
 set -x
 
 mkdir -p "$CPPCHECK_DIR"
 cd "${SOURCE_DIR}"
 cppcheck $COMMON_ARGS $INCLUDE_FLAGS \
-         --platform=unix64 \
-         --library=posix.cfg --library=bsd.cfg --library=gnu.cfg \
-         -U_WIN32 \
-         src/openvpn/ src/compat/ src/plugins/ sample/ \
-         tests/unit_tests/example_test/ tests/unit_tests/openvpn/ \
-         tests/unit_tests/plugins/
+    --platform=unix64 \
+    --library=posix.cfg --library=bsd.cfg --library=gnu.cfg \
+    -U_WIN32 \
+    src/openvpn/ src/compat/ src/plugins/ sample/ \
+    tests/unit_tests/example_test/ tests/unit_tests/openvpn/ \
+    tests/unit_tests/plugins/
 cppcheck $COMMON_ARGS \
-         --platform=win64 \
-         --library=windows.cfg \
-         -D_WIN32 \
-         -UTARGET_LINUX -UTARGET_FREEBSD -UTARGET_OPENBSD -UTARGET_NETBSD \
-         -UTARGET_DARWIN -UTARGET_ANDROID -UTARGET_SOLARIS -UTARGET_DRAGONFLY \
-         -UTARGET_AIX \
-         src/openvpn* src/compat/ \
-         tests/unit_tests/example_test/ tests/unit_tests/openvpn*
+    --platform=win64 \
+    --library=windows.cfg \
+    -D_WIN32 \
+    -UTARGET_LINUX -UTARGET_FREEBSD -UTARGET_OPENBSD -UTARGET_NETBSD \
+    -UTARGET_DARWIN -UTARGET_ANDROID -UTARGET_SOLARIS -UTARGET_DRAGONFLY \
+    -UTARGET_AIX \
+    src/openvpn* src/compat/ \
+    tests/unit_tests/example_test/ tests/unit_tests/openvpn*
diff --git a/dev-tools/update-copyright.sh b/dev-tools/update-copyright.sh
index 96546dd..7ca6002 100755
--- a/dev-tools/update-copyright.sh
+++ b/dev-tools/update-copyright.sh
@@ -34,8 +34,7 @@
 COPY_YEAR="$1"
 
 cd "$(git rev-parse --show-toplevel)"
-for file in $(git ls-files | grep -v vendor/);
-do
+for file in $(git ls-files | grep -v vendor/); do
     echo -n "Updating $file ..."
     # The first sed operation covers 20xx-20yy copyright lines,
     # The second sed operation changes 20xx -> 20xx-20yy
diff --git a/tests/lwip_client_up.sh b/tests/lwip_client_up.sh
index a6b4d24..b1941a4 100755
--- a/tests/lwip_client_up.sh
+++ b/tests/lwip_client_up.sh
@@ -2,16 +2,17 @@
 #
 # Determine the OpenVPN PID from its pid file. This works reliably even when
 # the OpenVPN process is backgrounded for parallel tests.
-MY_PPID=`cat $pid`
+MY_PPID=$(cat $pid)
 
 # Add this client's VPN IP and PID to a file. This enables
 # t_server_null_client.sh to kill this OpenVPN client after fping tests have
 # finished.
-echo "$ifconfig_local,$MY_PPID" >> ./$test_name.lwip
+echo "$ifconfig_local,$MY_PPID" >>./$test_name.lwip
 
 # Wait long enough to allow fping tests to finish. Also ensure that this
 # OpenVPN client is killed even if t_server_null_client.sh failed to do it.
-(sleep 15
-echo "ERROR: t_server_null_client.sh failed to kill OpenVPN client with PID $MY_PPID in test $test_name. Killing it in lwip_client_up.sh."
-kill -15 $MY_PPID
+(
+    sleep 15
+    echo "ERROR: t_server_null_client.sh failed to kill OpenVPN client with PID $MY_PPID in test $test_name. Killing it in lwip_client_up.sh."
+    kill -15 $MY_PPID
 ) &
diff --git a/tests/null_client_up.sh b/tests/null_client_up.sh
index d4df0c6..be339ee 100755
--- a/tests/null_client_up.sh
+++ b/tests/null_client_up.sh
@@ -4,8 +4,11 @@
 
 # Determine the OpenVPN PID from its pid file. This works reliably even when
 # the OpenVPN process is backgrounded for parallel tests.
-MY_PPID=`cat $pid`
+MY_PPID=$(cat $pid)
 
 # Allow OpenVPN to finish initializing while waiting in the background and then
 # killing the process gracefully.
-(sleep 5 ; kill -15 $MY_PPID) &
+(
+    sleep 5
+    kill -15 $MY_PPID
+) &
diff --git a/tests/t_client.sh.in b/tests/t_client.sh.in
index 2f37845..305441be 100755
--- a/tests/t_client.sh.in
+++ b/tests/t_client.sh.in
@@ -19,9 +19,9 @@
 srcdir="${srcdir:-.}"
 top_builddir="${top_builddir:-..}"
 openvpn="${openvpn:-${top_builddir}/src/openvpn/openvpn}"
-if [ -r "${top_builddir}"/t_client.rc ] ; then
+if [ -r "${top_builddir}"/t_client.rc ]; then
     . "${top_builddir}"/t_client.rc
-elif [ -r "${srcdir}"/t_client.rc ] ; then
+elif [ -r "${srcdir}"/t_client.rc ]; then
     . "${srcdir}"/t_client.rc
 else
     echo "$0: cannot find 't_client.rc' in build dir ('${top_builddir}')" >&2
@@ -32,37 +32,35 @@
 # Check for external dependencies
 FPING="fping"
 FPING6="fping6"
-which fping > /dev/null
+which fping >/dev/null
 if [ $? -ne 0 ]; then
     echo "$0: fping is not available in \$PATH" >&2
     exit "${TCLIENT_SKIP_RC}"
 fi
-which fping6 > /dev/null
+which fping6 >/dev/null
 if [ $? -ne 0 ]; then
     echo "$0: fping6 is not available in \$PATH, assuming fping 4.0 or later" >&2
     FPING="fping -4"
     FPING6="fping -6"
 fi
 
-KILL_EXEC=`which kill`
+KILL_EXEC=$(which kill)
 if [ $? -ne 0 ]; then
     echo "$0: kill not found in \$PATH" >&2
     exit "${TCLIENT_SKIP_RC}"
 fi
 
-if [ ! -x "${openvpn}" ]
-then
+if [ ! -x "${openvpn}" ]; then
     echo "no (executable) openvpn binary in current build tree. FAIL." >&2
     exit 1
 fi
 
-if [ ! -w . ]
-then
+if [ ! -w . ]; then
     echo "current directory is not writable (required for logging). FAIL." >&2
     exit 1
 fi
 
-if [ -z "$TEST_RUN_LIST" ] ; then
+if [ -z "$TEST_RUN_LIST" ]; then
     echo "TEST_RUN_LIST empty, no tests defined.  SKIP test." >&2
     exit "${TCLIENT_SKIP_RC}"
 fi
@@ -72,16 +70,14 @@
 
 # make sure we have permissions to run ifconfig/route from OpenVPN
 # can't use "id -u" here - doesn't work on Solaris
-ID=`id`
-if expr "$ID" : "uid=0" >/dev/null
-then :
+ID=$(id)
+if expr "$ID" : "uid=0" >/dev/null; then
+    :
 else
-    if [ "${PREFER_KSU}" -eq 1 ];
-    then
+    if [ "${PREFER_KSU}" -eq 1 ]; then
         # Check if we have a valid kerberos ticket
         klist -l 1>/dev/null 2>/dev/null
-        if [ $? -ne 0 ];
-        then
+        if [ $? -ne 0 ]; then
             # No kerberos ticket found, skip ksu and fallback to RUN_SUDO
             PREFER_KSU=0
             echo "$0: No Kerberos ticket available.  Will not use ksu."
@@ -90,8 +86,7 @@
         fi
     fi
 
-    if [ -z "$RUN_SUDO" ]
-    then
+    if [ -z "$RUN_SUDO" ]; then
         echo "$0: this test must run be as root, or RUN_SUDO=... " >&2
         echo "      must be set correctly in 't_client.rc'. SKIP." >&2
         exit "${TCLIENT_SKIP_RC}"
@@ -99,20 +94,19 @@
         # We have to use sudo. Make sure that we (hopefully) do not have
         # to ask the users password during the test. This is done to
         # prevent timing issues, e.g. when the waits for openvpn to start
-	if $RUN_SUDO $KILL_EXEC -0 $$
-	then
-	    echo "$0: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
-	else
-	    echo "$0: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
-	    exit "${TCLIENT_SKIP_RC}"
-	fi
+        if $RUN_SUDO $KILL_EXEC -0 $$; then
+            echo "$0: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
+        else
+            echo "$0: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
+            exit "${TCLIENT_SKIP_RC}"
+        fi
     fi
 fi
 
-LOGDIR=t_client-`hostname`-`date +%Y%m%d-%H%M%S`
+LOGDIR=t_client-$(hostname)-$(date +%Y%m%d-%H%M%S)
 LOGDIR_ABS="$PWD/$LOGDIR"
-if mkdir $LOGDIR
-then :
+if mkdir $LOGDIR; then
+    :
 else
     echo "can't create log directory '$LOGDIR'. FAIL." >&2
     exit 1
@@ -132,21 +126,28 @@
 output_start()
 {
     case $V in
-	0) outbuf="" ;;			# no per-test output at all
-	1) printf "$@\n"			# compact, details only on failure
-           outbuf="\n" ;;
-	*) printf "\n$@\n" ;;		# print all, with a bit formatting
+        0) outbuf="" ;; # no per-test output at all
+        1)
+            printf "$@\n" # compact, details only on failure
+            outbuf="\n"
+            ;;
+        *) printf "\n$@\n" ;; # print all, with a bit formatting
     esac
 }
 
 output()
 {
-    END_NL="\n"; if [ "X$1" = "X-n" ] ; then END_NL="" ; shift ; fi
+    END_NL="\n"
+    if [ "X$1" = "X-n" ]; then
+        END_NL=""
+        shift
+    fi
     case $V in
-	0) ;;				# no per-test output at all
-	1) outbuf="$outbuf$@${END_NL}"	# print details only on failure
-           ;;
-	*) printf "$@${END_NL}" ;;	# print everything
+        0) ;; # no per-test output at all
+        1)
+            outbuf="$outbuf$@${END_NL}" # print details only on failure
+            ;;
+        *) printf "$@${END_NL}" ;; # print everything
     esac
 }
 
@@ -154,62 +155,61 @@
 fail()
 {
     output "FAIL: $@\n"
-    fail_count=$(( $fail_count + 1 ))
+    fail_count=$(($fail_count + 1))
 }
 
 # print "all interface IP addresses" + "all routes"
 # this is higly system dependent...
 get_ifconfig_route()
 {
-    UNAME=`uname -s`
+    UNAME=$(uname -s)
     case $UNAME in
-	Linux)
+        Linux)
             # linux / iproute2? (-> if configure got a path)
-            if [ -n "@IPROUTE@" ]
-            then
+            if [ -n "@IPROUTE@" ]; then
                 echo "-- linux iproute2 --"
-                @IPROUTE@ addr show     | grep -v valid_lft
+                @IPROUTE@ addr show | grep -v valid_lft
                 @IPROUTE@ route show
                 @IPROUTE@ -o -6 route show | grep -v ' cache' | sed -E -e 's/ expires [0-9]*sec//' -e 's/ (mtu|hoplimit|cwnd|ssthresh) [0-9]+//g' -e 's/ (rtt|rttvar) [0-9]+ms//g'
             else
-	        echo "-- linux / ifconfig --"
-	        LANG=C @IFCONFIG@ -a |egrep  "( addr:|encap:)"
-	        LANG=C @NETSTAT@ -rn -4 -6
+                echo "-- linux / ifconfig --"
+                LANG=C @IFCONFIG@ -a | egrep "( addr:|encap:)"
+                LANG=C @NETSTAT@ -rn -4 -6
             fi
             ;;
-	FreeBSD|NetBSD|Darwin)
-	   echo "-- FreeBSD/NetBSD/Darwin [MacOS X] --"
-	   @IFCONFIG@ -a | egrep "(flags=|inet)"
-	   @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
-	   ;;
-	OpenBSD)
-	   echo "-- OpenBSD --"
-	   @IFCONFIG@ -a | egrep "(flags=|inet)" | \
-		sed -e 's/pltime [0-9]*//' -e 's/vltime [0-9]*//'
-	   @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
-	   ;;
-	SunOS)
-	   echo "-- Solaris --"
-	   @IFCONFIG@ -a | egrep "(flags=|inet)"
-	   @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
-	   ;;
-	AIX)
-	   echo "-- AIX --"
-	   @IFCONFIG@ -a | egrep "(flags=|inet)"
-	   @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
-	   ;;
+        FreeBSD | NetBSD | Darwin)
+            echo "-- FreeBSD/NetBSD/Darwin [MacOS X] --"
+            @IFCONFIG@ -a | egrep "(flags=|inet)"
+            @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
+            ;;
+        OpenBSD)
+            echo "-- OpenBSD --"
+            @IFCONFIG@ -a | egrep "(flags=|inet)" |
+                sed -e 's/pltime [0-9]*//' -e 's/vltime [0-9]*//'
+            @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
+            ;;
+        SunOS)
+            echo "-- Solaris --"
+            @IFCONFIG@ -a | egrep "(flags=|inet)"
+            @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
+            ;;
+        AIX)
+            echo "-- AIX --"
+            @IFCONFIG@ -a | egrep "(flags=|inet)"
+            @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
+            ;;
         *)
-           echo "get_ifconfig_route(): no idea how to get info on your OS (`uname -s`).  FAIL." >&2
-           exit 20
-           ;;
+            echo "get_ifconfig_route(): no idea how to get info on your OS ($(uname -s)).  FAIL." >&2
+            exit 20
+            ;;
     esac
 
     # another round of per-platform information gathering, for DNS info
     # for most of the platforms "cat /etc/resolv.conf" is good enough
     # except Linux and MacOS
     case $UNAME in
-	Linux)
-            if [ -x /usr/bin/resolvectl -a -d /run/systemd/system ] ; then
+        Linux)
+            if [ -x /usr/bin/resolvectl -a -d /run/systemd/system ]; then
                 echo "-- linux resolvectl --"
                 resolvectl status
             else
@@ -217,7 +217,7 @@
                 cat /etc/resolv.conf
             fi
             ;;
-	Darwin)
+        Darwin)
             echo "-- MacOS scutil --dns"
             scutil --dns
             ;;
@@ -234,19 +234,19 @@
 #  arg2: IPv4/IPv6 address that must show up in out of "get_ifconfig_route"
 check_ifconfig()
 {
-    proto=$1 ; shift
+    proto=$1
+    shift
     expect_list="$@"
 
-    if [ -z "$expect_list" ] ; then return ; fi
-    if [ "$expect_list" = "-" ] ; then return ; fi
+    if [ -z "$expect_list" ]; then return; fi
+    if [ "$expect_list" = "-" ]; then return; fi
 
-    for expect in $expect_list
-    do
-	if get_ifconfig_route | fgrep "$expect" >/dev/null
-	then :
-	else
-	    fail "check_ifconfig(): expected IPv$proto address '$expect' not found in ifconfig output."
-	fi
+    for expect in $expect_list; do
+        if get_ifconfig_route | fgrep "$expect" >/dev/null; then
+            :
+        else
+            fail "check_ifconfig(): expected IPv$proto address '$expect' not found in ifconfig output."
+        fi
     done
 }
 
@@ -257,47 +257,48 @@
 #  arg3... -> fping arguments (host list)
 run_ping_tests()
 {
-    proto=$1 ; want=$2 ; shift ; shift
+    proto=$1
+    want=$2
+    shift
+    shift
     targetlist="$@"
 
     # "no targets" is fine
-    if [ -z "$targetlist" ] ; then return ; fi
+    if [ -z "$targetlist" ]; then return; fi
 
     case $proto in
-	4) cmd="$FPING" ;;
-	6) cmd="$FPING6" ;;
-	*) echo "internal error in run_ping_tests arg 1: '$proto'" >&2
-	   exit 1 ;;
+        4) cmd="$FPING" ;;
+        6) cmd="$FPING6" ;;
+        *)
+            echo "internal error in run_ping_tests arg 1: '$proto'" >&2
+            exit 1
+            ;;
     esac
 
     case $want in
-	want_ok)   sizes_list="64 1440 3000" ;;
-	want_fail) sizes_list="64" ;;
+        want_ok) sizes_list="64 1440 3000" ;;
+        want_fail) sizes_list="64" ;;
     esac
 
-    for bytes in $sizes_list
-    do
-	output "run IPv$proto ping tests ($want), $bytes byte packets..."
+    for bytes in $sizes_list; do
+        output "run IPv$proto ping tests ($want), $bytes byte packets..."
 
-	echo "$cmd -b $bytes -C 20 -p 250 -q $fping_args $targetlist" >>$LOGDIR/$SUF:fping.out
-	$cmd -b $bytes -C 20 -p 250 -q $fping_args $targetlist >>$LOGDIR/$SUF:fping.out 2>&1
+        echo "$cmd -b $bytes -C 20 -p 250 -q $fping_args $targetlist" >>$LOGDIR/$SUF:fping.out
+        $cmd -b $bytes -C 20 -p 250 -q $fping_args $targetlist >>$LOGDIR/$SUF:fping.out 2>&1
 
-	# while OpenVPN is running, pings must succeed (want='want_ok')
-	# before OpenVPN is up, pings must NOT succeed (want='want_fail')
+        # while OpenVPN is running, pings must succeed (want='want_ok')
+        # before OpenVPN is up, pings must NOT succeed (want='want_fail')
 
-	rc=$?
-	if [ $rc = 0 ] 				# all ping OK
-	then
-	    if [ $want = "want_fail" ]		# not what we want
-	    then
-		fail "IPv$proto ping test succeeded, but needs to *fail*."
-	    fi
-	else					# ping failed
-	    if [ $want = "want_ok" ]		# not what we wanted
-	    then
-		fail "IPv$proto ping test ($bytes bytes) failed, but should succeed."
-	    fi
-	fi
+        rc=$?
+        if [ $rc = 0 ]; then                 # all ping OK
+            if [ $want = "want_fail" ]; then # not what we want
+                fail "IPv$proto ping test succeeded, but needs to *fail*."
+            fi
+        else                               # ping failed
+            if [ $want = "want_ok" ]; then # not what we wanted
+                fail "IPv$proto ping test ($bytes bytes) failed, but should succeed."
+            fi
+        fi
     done
 }
 
@@ -308,8 +309,7 @@
 SUMMARY_SKIP=
 SUMMARY_FAIL=
 
-for SUF in $TEST_RUN_LIST
-do
+for SUF in $TEST_RUN_LIST; do
     # get config variables
     eval test_prep=\"\$PREPARE_$SUF\"
     eval test_check_skip=\"\$CHECK_SKIP_$SUF\"
@@ -336,11 +336,13 @@
 
     if [ -n "$test_check_skip" ]; then
         output "check whether we need to skip: '$test_check_skip'"
-        if eval $test_check_skip; then :
+        if eval $test_check_skip; then
+            :
         else
             output "skip check failed, SKIP test $SUF."
-	    SUMMARY_SKIP="$SUMMARY_SKIP $SUF"
-	    printf "$outbuf" ; continue
+            SUMMARY_SKIP="$SUMMARY_SKIP $SUF"
+            printf "$outbuf"
+            continue
         fi
     fi
 
@@ -355,13 +357,14 @@
     output "\nrun pre-openvpn ping tests - targets must not be reachable..."
     run_ping_tests 4 want_fail "$ping4_hosts"
     run_ping_tests 6 want_fail "$ping6_hosts"
-    if [ "$fail_count" = 0 ] ; then
+    if [ "$fail_count" = 0 ]; then
         output "OK.\n"
     else
-	fail "make sure that ping hosts are ONLY reachable via VPN, SKIP test $SUF."
-	SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
-	exit_code=31
-	printf "$outbuf" ; continue
+        fail "make sure that ping hosts are ONLY reachable via VPN, SKIP test $SUF."
+        SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
+        exit_code=31
+        printf "$outbuf"
+        continue
     fi
 
     pidfile="$LOGDIR_ABS/openvpn-$SUF.pid"
@@ -376,18 +379,17 @@
     # to $ovpn_init_check times.
     ovpn_init_check=30
     ovpn_init_success=0
-    while [ $ovpn_init_check -gt 0 ];
-    do
-       sleep 1  # Wait for OpenVPN to initialize and have had time to write the pid file
-       grep "Initialization Sequence Completed" $LOGDIR/$SUF:openvpn.log >/dev/null
-       if [ $? -eq 0 ]; then
-           ovpn_init_check=0
-           ovpn_init_success=1
-       fi
-       ovpn_init_check=$(( $ovpn_init_check - 1 ))
+    while [ $ovpn_init_check -gt 0 ]; do
+        sleep 1 # Wait for OpenVPN to initialize and have had time to write the pid file
+        grep "Initialization Sequence Completed" $LOGDIR/$SUF:openvpn.log >/dev/null
+        if [ $? -eq 0 ]; then
+            ovpn_init_check=0
+            ovpn_init_success=1
+        fi
+        ovpn_init_check=$(($ovpn_init_check - 1))
     done
 
-    opid=`cat $pidfile`
+    opid=$(cat $pidfile)
     if [ -n "$opid" ]; then
         output "  OpenVPN running with PID $opid"
     else
@@ -398,16 +400,17 @@
     if [ $ovpn_init_success -ne 1 -o -z "$opid" ]; then
         output "$0:  OpenVPN did not initialize in a reasonable time"
         if [ -n "$opid" ]; then
-           $RUN_SUDO $KILL_EXEC $opid
+            $RUN_SUDO $KILL_EXEC $opid
         fi
         $RUN_SUDO $KILL_EXEC $sudopid
-	output "tail -5 $SUF:openvpn.log"
-	output "`tail -5 $LOGDIR/$SUF:openvpn.log`"
-	fail "skip rest of sub-tests for test run $SUF."
-	trap - 0 1 2 3 15
-	SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
-	exit_code=30
-	printf "$outbuf" ; continue
+        output "tail -5 $SUF:openvpn.log"
+        output "$(tail -5 $LOGDIR/$SUF:openvpn.log)"
+        fail "skip rest of sub-tests for test run $SUF."
+        trap - 0 1 2 3 15
+        SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
+        exit_code=30
+        printf "$outbuf"
+        continue
     fi
 
     # make sure openvpn client is terminated in case shell exits
@@ -418,17 +421,16 @@
     output "save ifconfig+route"
     get_ifconfig_route >$LOGDIR/$SUF:ifconfig_route.txt
 
-    if [ "$expect_ifconfig4" = "-" ] ; then
+    if [ "$expect_ifconfig4" = "-" ]; then
         output "skip ifconfig+route check"
     else
-	output -n "compare pre-openvpn ifconfig+route with current values..."
-	if diff $LOGDIR/$SUF:ifconfig_route_pre.txt \
-		$LOGDIR/$SUF:ifconfig_route.txt >/dev/null
-	then
-	    fail "no differences between ifconfig/route before OpenVPN start and now."
-	else
-	    output " OK!\n"
-	fi
+        output -n "compare pre-openvpn ifconfig+route with current values..."
+        if diff $LOGDIR/$SUF:ifconfig_route_pre.txt \
+            $LOGDIR/$SUF:ifconfig_route.txt >/dev/null; then
+            fail "no differences between ifconfig/route before OpenVPN start and now."
+        else
+            output " OK!\n"
+        fi
     fi
 
     # post init script needed?
@@ -449,8 +451,8 @@
     $RUN_SUDO $KILL_EXEC $opid
     wait $!
     rc=$?
-    if [ $rc != 0 ] ; then
-	fail "OpenVPN return code $rc, expect 0"
+    if [ $rc != 0 ]; then
+        fail "OpenVPN return code $rc, expect 0"
     fi
 
     output "\nsave post-openvpn ifconfig + route..."
@@ -458,23 +460,22 @@
 
     output -n "compare pre- and post-openvpn ifconfig + route..."
     if diff $LOGDIR/$SUF:ifconfig_route_pre.txt \
-	    $LOGDIR/$SUF:ifconfig_route_post.txt >$LOGDIR/$SUF:ifconfig_route_diff.txt
-    then
-	output " OK.\n"
+        $LOGDIR/$SUF:ifconfig_route_post.txt >$LOGDIR/$SUF:ifconfig_route_diff.txt; then
+        output " OK.\n"
     else
-	output "\n\n" "`cat $LOGDIR/$SUF:ifconfig_route_diff.txt`" "\n"
-	fail "differences between pre- and post-ifconfig/route."
+        output "\n\n" "$(cat $LOGDIR/$SUF:ifconfig_route_diff.txt)" "\n"
+        fail "differences between pre- and post-ifconfig/route."
     fi
-    if [ "$fail_count" = 0 ] ; then
+    if [ "$fail_count" = 0 ]; then
         output "test run $SUF: all tests OK.\n"
-	SUMMARY_OK="$SUMMARY_OK $SUF"
+        SUMMARY_OK="$SUMMARY_OK $SUF"
     else
-	if [ "$V" -gt 0 ] ; then
-	    printf "$outbuf"
-	    echo "test run $SUF: $fail_count test failures. FAIL."
+        if [ "$V" -gt 0 ]; then
+            printf "$outbuf"
+            echo "test run $SUF: $fail_count test failures. FAIL."
         fi
-	SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
-	exit_code=30
+        SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
+        exit_code=30
     fi
 
     if [ -n "$test_cleanup" ]; then
@@ -484,9 +485,9 @@
 
 done
 
-if [ -z "$SUMMARY_OK" ] ; then SUMMARY_OK=" none"; fi
-if [ -z "$SUMMARY_SKIP" ] ; then SUMMARY_SKIP=" none"; fi
-if [ -z "$SUMMARY_FAIL" ] ; then SUMMARY_FAIL=" none"; fi
+if [ -z "$SUMMARY_OK" ]; then SUMMARY_OK=" none"; fi
+if [ -z "$SUMMARY_SKIP" ]; then SUMMARY_SKIP=" none"; fi
+if [ -z "$SUMMARY_FAIL" ]; then SUMMARY_FAIL=" none"; fi
 echo "Test sets succeeded:$SUMMARY_OK."
 echo "Test sets skipped:$SUMMARY_SKIP."
 echo "Test sets failed:$SUMMARY_FAIL."
diff --git a/tests/t_cltsrv.sh b/tests/t_cltsrv.sh
index 6b7df65..03c3845 100755
--- a/tests/t_cltsrv.sh
+++ b/tests/t_cltsrv.sh
@@ -24,50 +24,58 @@
 trap "rm -f log.$$ log.$$.signal ; trap 0 ; exit 77" 1 2 15
 trap "rm -f log.$$ log.$$.signal ; exit 1" 0 3
 addopts=
-case `uname -s` in
+case $(uname -s) in
     FreeBSD)
-    # FreeBSD jails map the outgoing IP to the jail IP - we need to
-    # allow the real IP unless we want the test to run forever.
-    if test "`sysctl 2>/dev/null -n security.jail.jailed`" = 1 \
-    || ps -ostate= -p $$ | grep -q J; then
-	addopts="--float"
-	if test "x`ifconfig | grep inet`" = x ; then
-	    echo "###"
-	    echo "### To run the test in a FreeBSD jail, you MUST add an IP alias for the jail's IP."
-	    echo "###"
-	    exit 77
-	fi
-    fi
-    ;;
+        # FreeBSD jails map the outgoing IP to the jail IP - we need to
+        # allow the real IP unless we want the test to run forever.
+        if test "$(sysctl 2>/dev/null -n security.jail.jailed)" = 1 ||
+            ps -ostate= -p $$ | grep -q J; then
+            addopts="--float"
+            if test "x$(ifconfig | grep inet)" = x; then
+                echo "###"
+                echo "### To run the test in a FreeBSD jail, you MUST add an IP alias for the jail's IP."
+                echo "###"
+                exit 77
+            fi
+        fi
+        ;;
 esac
 
 # make sure that the --down script is executable -- fail (rather than
 # skip) test if it isn't.
 downscript="../tests/t_cltsrv-down.sh"
 root="${top_srcdir}/sample"
-test -x "${root}/${downscript}" || chmod +x "${root}/${downscript}" || { echo >&2 "${root}/${downscript} is not executable, failing." ; exit 1 ; }
+test -x "${root}/${downscript}" || chmod +x "${root}/${downscript}" || {
+    echo >&2 "${root}/${downscript} is not executable, failing."
+    exit 1
+}
 echo "The following test will take about two minutes." >&2
 echo "If the addresses are in use, this test will retry up to two times." >&2
 
 # go
 success=0
-for i in 1 2 3 ; do
-  set +e
-  (
-  "${openvpn}" --script-security 2 --cd "${root}" ${addopts} --setenv role srv --down "${downscript}" --tls-exit --ping-exit 180 --config "sample-config-files/loopback-server" &
-  "${openvpn}" --script-security 2 --cd "${top_srcdir}/sample" ${addopts} --setenv role clt --down "${downscript}" --tls-exit --ping-exit 180 --config "sample-config-files/loopback-client"
-  ) 3>log.$$.signal >log.$$ 2>&1
-  e1=$?
-  wait $!
-  e2=$?
-  grep 'TCP/UDP: Socket bind failed on local address.*in use' log.$$ >/dev/null && {
-    echo 'address in use, retrying in 150 s'
-    sleep 150
-    continue
-  }
-  grep -v ':inactive$' log.$$.signal >/dev/null && { cat log.$$.signal ; echo ; cat log.$$ ; exit 1 ; }
-  success=1
-  break
+for i in 1 2 3; do
+    set +e
+    (
+        "${openvpn}" --script-security 2 --cd "${root}" ${addopts} --setenv role srv --down "${downscript}" --tls-exit --ping-exit 180 --config "sample-config-files/loopback-server" &
+        "${openvpn}" --script-security 2 --cd "${top_srcdir}/sample" ${addopts} --setenv role clt --down "${downscript}" --tls-exit --ping-exit 180 --config "sample-config-files/loopback-client"
+    ) 3>log.$$.signal >log.$$ 2>&1
+    e1=$?
+    wait $!
+    e2=$?
+    grep 'TCP/UDP: Socket bind failed on local address.*in use' log.$$ >/dev/null && {
+        echo 'address in use, retrying in 150 s'
+        sleep 150
+        continue
+    }
+    grep -v ':inactive$' log.$$.signal >/dev/null && {
+        cat log.$$.signal
+        echo
+        cat log.$$
+        exit 1
+    }
+    success=1
+    break
 done
 
 set -e
@@ -75,14 +83,14 @@
 # exit code - defaults to 0, PASS
 ec=0
 
-if [ $success != 1 ] ; then
-  # couldn't run test -- addresses in use, skip test
-  cat log.$$
-  ec=77
-elif [ $e1 != 0 ] || [ $e2 != 0 ] ; then
-  # failure -- fail test
-  cat log.$$
-  ec=1
+if [ $success != 1 ]; then
+    # couldn't run test -- addresses in use, skip test
+    cat log.$$
+    ec=77
+elif [ $e1 != 0 ] || [ $e2 != 0 ]; then
+    # failure -- fail test
+    cat log.$$
+    ec=1
 fi
 
 rm log.$$ log.$$.signal
diff --git a/tests/t_lpback.sh b/tests/t_lpback.sh
index 6802506..058206f 100755
--- a/tests/t_lpback.sh
+++ b/tests/t_lpback.sh
@@ -37,51 +37,56 @@
 test_start()
 {
     case $V in
-        0) outbuf="" ;;                  # no per-test output at all
-        1) outbuf="$@" ;;                # compact, details only on failure
-        *) printf "$@" ;;                # print all
+        0) outbuf="" ;;   # no per-test output at all
+        1) outbuf="$@" ;; # compact, details only on failure
+        *) printf "$@" ;; # print all
     esac
 }
 test_end()
 {
-    RC=$1 ; LOG=$2
-    if [ $RC != 0 ]
-    then
+    RC=$1
+    LOG=$2
+    if [ $RC != 0 ]; then
         case $V in
-            0) ;;                                # no per-test output
-            1) echo "$outbuf" "FAIL (RC=$RC)"; cat $LOG ;;
-            *) echo "FAIL (RC=$RC)"; cat $LOG ;;
+            0) ;; # no per-test output
+            1)
+                echo "$outbuf" "FAIL (RC=$RC)"
+                cat $LOG
+                ;;
+            *)
+                echo "FAIL (RC=$RC)"
+                cat $LOG
+                ;;
         esac
         e=1
-        tests_failed=$(( $tests_failed + 1 ))
+        tests_failed=$(($tests_failed + 1))
     else
         case $V in
-            0|1) ;;                              # no per-test output for 'OK'
-            *) echo "OK"                         # print all
+            0 | 1) ;;       # no per-test output for 'OK'
+            *) echo "OK" ;; # print all
         esac
-        tests_passed=$(( $tests_passed + 1 ))
+        tests_passed=$(($tests_passed + 1))
     fi
 }
 
 # if running with V=1, give an indication what test runs now
-if [ "$V" = 1  ] ; then
+if [ "$V" = 1 ]; then
     echo "$0: running with V=$V, only printing test fails"
 fi
 
-
 # Get list of supported ciphers from openvpn --show-ciphers output
-CIPHERS=$(${openvpn} --show-ciphers | \
-            sed -e '/The following/,/^$/d' -e s'/ .*//' -e '/^[[:space:]]*$/d')
+CIPHERS=$(${openvpn} --show-ciphers |
+    sed -e '/The following/,/^$/d' -e s'/ .*//' -e '/^[[:space:]]*$/d')
 
 # SK, 2014-06-04: currently the DES-EDE3-CFB1 implementation of OpenSSL is
 # broken (see http://rt.openssl.org/Ticket/Display.html?id=2867), so exclude
 # that cipher from this test.
 # GD, 2014-07-06 so is DES-CFB1
 # GD, 2014-07-06 do not test RC5-* either (fails on NetBSD w/o libcrypto_rc5)
-CIPHERS=$(echo "$CIPHERS" | egrep -v '^(DES-EDE3-CFB1|DES-CFB1|RC5-)' )
+CIPHERS=$(echo "$CIPHERS" | egrep -v '^(DES-EDE3-CFB1|DES-CFB1|RC5-)')
 
 e=0
-if [ -z "$CIPHERS" ] ; then
+if [ -z "$CIPHERS" ]; then
     echo "'openvpn --show-ciphers' FAILED (empty list)"
     e=1
 fi
@@ -91,10 +96,9 @@
 
 set +e
 
-for cipher in ${CIPHERS}
-do
+for cipher in ${CIPHERS}; do
     test_start "Testing cipher ${cipher}... "
-    ( "${openvpn}" --test-crypto --cipher ${cipher} ) >log.$$ 2>&1
+    ("${openvpn}" --test-crypto --cipher ${cipher}) >log.$$ 2>&1
     test_end $? log.$$
 done
 
@@ -121,7 +125,7 @@
     >log.$$ 2>&1
 test_end $? log.$$
 
-if [ "$V" -ge 1  ] ; then
+if [ "$V" -ge 1 ]; then
     echo "$0: tests passed: $tests_passed  failed: $tests_failed"
 fi
 
diff --git a/tests/t_net.sh b/tests/t_net.sh
index 8134832..17e028e 100755
--- a/tests/t_net.sh
+++ b/tests/t_net.sh
@@ -9,7 +9,6 @@
 top_builddir="${top_builddir:-..}"
 openvpn="${openvpn:-${top_builddir}/src/openvpn/openvpn}"
 
-
 # bail out right away on non-linux. NetLink (the object of this test) is only
 # used on Linux, therefore testing other platform is not needed.
 #
@@ -69,7 +68,6 @@
     done
 }
 
-
 ## execution starts here
 
 # t_client.rc required only for RUN_SUDO definition
@@ -89,21 +87,18 @@
     exit 77
 fi
 
-
 # Ensure PREFER_KSU is in a known state
 PREFER_KSU="${PREFER_KSU:-0}"
 
 # make sure we have permissions to run the networking unit-test
-ID=`id`
-if expr "$ID" : "uid=0" >/dev/null
-then :
+ID=$(id)
+if expr "$ID" : "uid=0" >/dev/null; then
+    :
 else
-    if [ "${PREFER_KSU}" -eq 1 ];
-    then
+    if [ "${PREFER_KSU}" -eq 1 ]; then
         # Check if we have a valid kerberos ticket
         klist -l 1>/dev/null 2>/dev/null
-        if [ $? -ne 0 ];
-        then
+        if [ $? -ne 0 ]; then
             # No kerberos ticket found, skip ksu and fallback to RUN_SUDO
             PREFER_KSU=0
             echo "$0: No Kerberos ticket available.  Will not use ksu."
@@ -112,16 +107,14 @@
         fi
     fi
 
-    if [ -z "$RUN_SUDO" ]
-    then
+    if [ -z "$RUN_SUDO" ]; then
         echo "$0: no RUN_SUDO=... in t_client.rc or environment, defaulting to 'sudo'." >&2
         echo "      if that does not work, set RUN_SUDO= correctly for your system." >&2
         RUN_SUDO="sudo"
     fi
 
     # check that we can run the unit-test binary with sudo
-    if $RUN_SUDO $UNIT_TEST test
-    then
+    if $RUN_SUDO $UNIT_TEST test; then
         echo "$0: $RUN_SUDO $UNIT_TEST succeeded, good."
     else
         echo "$0: $RUN_SUDO $UNIT_TEST failed, cannot go on. SKIP." >&2
diff --git a/tests/t_server_null.sh b/tests/t_server_null.sh
index 74ffd52..c633614 100755
--- a/tests/t_server_null.sh
+++ b/tests/t_server_null.sh
@@ -2,7 +2,7 @@
 #
 TSERVER_NULL_SKIP_RC="${TSERVER_NULL_SKIP_RC:-77}"
 
-if ! [ -r "./t_server_null.rc" ] ; then
+if ! [ -r "./t_server_null.rc" ]; then
     echo "${0}: cannot find './t_server_null.rc. SKIPPING TEST.'" >&2
     exit "${TSERVER_NULL_SKIP_RC}"
 fi
@@ -22,11 +22,10 @@
 # make sure we have permissions to run ifconfig/route from OpenVPN
 # can't use "id -u" here - doesn't work on Solaris
 ID=$(id)
-if expr "$ID" : "uid=0" >/dev/null
-then :
+if expr "$ID" : "uid=0" >/dev/null; then
+    :
 else
-    if [ "${PREFER_KSU}" -eq 1 ];
-    then
+    if [ "${PREFER_KSU}" -eq 1 ]; then
         # Check if we have a valid kerberos ticket
         if klist -l 1>/dev/null 2>/dev/null; then
             RUN_SUDO="ksu -q -e"
@@ -37,26 +36,24 @@
         fi
     fi
 
-    if [ -z "$RUN_SUDO" ]
-    then
+    if [ -z "$RUN_SUDO" ]; then
         echo "${0}: this test must run be as root, or RUN_SUDO=... " >&2
         echo "      must be set correctly in 't_server_null.rc'. SKIP." >&2
         exit "${TSERVER_NULL_SKIP_RC}"
     else
-	# Run a no-op command with privilege escalation (e.g. sudo) so that
-	# we (hopefully) do not have to ask the users password during the test.
-	if $RUN_SUDO "${KILL_EXEC}" -0 $$
-	then
-	    echo "${0}: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
-	else
-	    echo "${0}: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
-	    exit "${TSERVER_NULL_SKIP_RC}"
-	fi
+        # Run a no-op command with privilege escalation (e.g. sudo) so that
+        # we (hopefully) do not have to ask the users password during the test.
+        if $RUN_SUDO "${KILL_EXEC}" -0 $$; then
+            echo "${0}: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
+        else
+            echo "${0}: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
+            exit "${TSERVER_NULL_SKIP_RC}"
+        fi
     fi
 fi
 
 srcdir="${srcdir:-.}"
-export t_server_null_logdir=t_server_null-`hostname`-`date +%Y%m%d-%H%M%S`
+export t_server_null_logdir=t_server_null-$(hostname)-$(date +%Y%m%d-%H%M%S)
 
 # Create directory for server and client logs
 mkdir $t_server_null_logdir
diff --git a/tests/t_server_null_client.sh b/tests/t_server_null_client.sh
index 1745de5..3203cc2 100755
--- a/tests/t_server_null_client.sh
+++ b/tests/t_server_null_client.sh
@@ -1,9 +1,10 @@
 #!/bin/sh
 
-should_run_test() {
+should_run_test()
+{
     test_name="$1"
 
-    if echo "$test_name"|grep -q _lwip; then
+    if echo "$test_name" | grep -q _lwip; then
         if [ "$has_lwipovpn" = "no" ]; then
             return 1
         fi
@@ -12,7 +13,8 @@
     return 0
 }
 
-launch_client() {
+launch_client()
+{
     test_name=$1
     log="${test_name}.log"
     pid="${test_name}.pid"
@@ -30,7 +32,8 @@
         --log "${t_server_null_logdir}/${log}" &
 }
 
-ping_and_kill() {
+ping_and_kill()
+{
     if fping -q -c 5 $1; then
         echo "PASS: fping lwipovpn client $target"
     else
@@ -46,9 +49,10 @@
     kill -15 $2
 }
 
-ping_lwip_clients() {
+ping_lwip_clients()
+{
     if [ "$has_lwipovpn" = "yes" ]; then
-        lwip_client_count=$(echo "$lwip_test_names"|wc -w|tr -d " ")
+        lwip_client_count=$(echo "$lwip_test_names" | wc -w | tr -d " ")
     else
         lwip_client_count=0
     fi
@@ -60,10 +64,10 @@
     count=0
     maxcount=10
     while [ $count -le $maxcount ]; do
-        lwip_client_ips=$(cat ./*.lwip 2>/dev/null|wc -l)
+        lwip_client_ips=$(cat ./*.lwip 2>/dev/null | wc -l)
         if [ $lwip_client_ips -lt $lwip_client_count ]; then
             echo "Waiting for LWIP clients to start up ($count/$maxcount)"
-            count=$(( count + 1))
+            count=$((count + 1))
             sleep 1
         else
             echo "$lwip_client_ips/$lwip_client_count LWIP clients up"
@@ -73,8 +77,8 @@
 
     wait_pids=""
     for line in $(cat ./*.lwip 2>/dev/null); do
-        target_ip=$(echo $line|cut -d "," -f 1)
-        client_pid=$(echo $line|cut -d "," -f 2)
+        target_ip=$(echo $line | cut -d "," -f 1)
+        client_pid=$(echo $line | cut -d "," -f 2)
         ping_and_kill $target_ip $client_pid &
         wait_pids="$wait_pids $!"
     done
@@ -84,7 +88,8 @@
     test -e ./lwip_failed && return 1 || return 0
 }
 
-wait_for_results() {
+wait_for_results()
+{
     tests_running="yes"
 
     # Wait a bit to allow an OpenVPN client process to create a pidfile to
@@ -106,12 +111,13 @@
     done
 }
 
-get_client_test_result() {
+get_client_test_result()
+{
     test_name=$1
     should_pass=$2
     log="${test_name}.log"
 
-    grep "Initialization Sequence Completed" "${t_server_null_logdir}/${log}" > /dev/null
+    grep "Initialization Sequence Completed" "${t_server_null_logdir}/${log}" >/dev/null
     exit_code=$?
 
     if [ $exit_code -eq 0 ] && [ "${should_pass}" = "yes" ]; then
@@ -144,7 +150,7 @@
 server_max_wait=15
 while [ $count -lt $server_max_wait ]; do
     servers_up=0
-    server_count=$(echo "$TEST_SERVER_LIST"|wc -w|tr -d " ")
+    server_count=$(echo "$TEST_SERVER_LIST" | wc -w | tr -d " ")
 
     # We need to trim single-quotes because some shells return quoted values
     # and some don't. Using "set -o posix" which would resolve this problem is
@@ -152,13 +158,13 @@
     #
     # While inactive server configurations may get checked they won't increase
     # the active server count as the processes won't be running.
-    for i in $(set|grep 'SERVER_NAME_'|cut -d "=" -f 2|tr -d "[\']"); do
-        server_pid=$(cat "$i.pid" 2> /dev/null)
-        if [ -z "$server_pid" ] ; then
+    for i in $(set | grep 'SERVER_NAME_' | cut -d "=" -f 2 | tr -d "[\']"); do
+        server_pid=$(cat "$i.pid" 2>/dev/null)
+        if [ -z "$server_pid" ]; then
             continue
         fi
-        if $RUN_SUDO kill -0 $server_pid > /dev/null 2>&1; then
-            servers_up=$(( $servers_up + 1 ))
+        if $RUN_SUDO kill -0 $server_pid >/dev/null 2>&1; then
+            servers_up=$(($servers_up + 1))
         fi
     done
 
@@ -168,7 +174,7 @@
         retval=0
         break
     else
-        count=$(( count + 1))
+        count=$((count + 1))
         sleep 1
     fi
 
@@ -199,15 +205,14 @@
 # safe to check the test results.
 test_names=""
 lwip_test_names=""
-for SUF in $TEST_RUN_LIST
-do
+for SUF in $TEST_RUN_LIST; do
     eval test_name=\"\$TEST_NAME_$SUF\"
     eval client_exec=\"\$CLIENT_EXEC_$SUF\"
     eval client_conf=\"\$CLIENT_CONF_$SUF\"
 
     test_names="${test_names} ${test_name}"
 
-    if echo "$test_name"|grep -q _lwip; then
+    if echo "$test_name" | grep -q _lwip; then
         lwip_test_names="${lwip_test_names} ${test_name}"
     fi
 
@@ -219,13 +224,11 @@
 ping_lwip_clients
 retval=$?
 
-
 # Wait until all OpenVPN clients have exited
 (wait_for_results)
 
 # Check test results
-for SUF in $TEST_RUN_LIST
-do
+for SUF in $TEST_RUN_LIST; do
     eval test_name=\"\$TEST_NAME_$SUF\"
     eval should_pass=\"\$SHOULD_PASS_$SUF\"
 
diff --git a/tests/t_server_null_server.sh b/tests/t_server_null_server.sh
index e1775f0..a8d7268 100755
--- a/tests/t_server_null_server.sh
+++ b/tests/t_server_null_server.sh
@@ -1,6 +1,7 @@
 #!/bin/sh
 
-launch_server() {
+launch_server()
+{
     server_name=$1
     server_exec=$2
     server_conf=$3
@@ -17,10 +18,10 @@
 
     # Try to launch the server
     $RUN_SUDO "${server_exec}" \
-               $server_conf \
-               --status "${status}" 1 \
-               --writepid "${pid}" \
-               --explicit-exit-notify 3 > "$log" 2>&1 &
+        $server_conf \
+        --status "${status}" 1 \
+        --writepid "${pid}" \
+        --explicit-exit-notify 3 >"$log" 2>&1 &
 
     sleep 1
 
@@ -44,8 +45,7 @@
 retval=0
 
 # Launch test servers
-for SUF in $TEST_SERVER_LIST
-do
+for SUF in $TEST_SERVER_LIST; do
     eval server_name=\"\$SERVER_NAME_$SUF\"
     eval server_exec=\"\$SERVER_EXEC_$SUF\"
     eval server_conf=\"\$SERVER_CONF_$SUF\"
@@ -57,8 +57,7 @@
 # the test run.
 #
 export server_pid_files=""
-for SUF in $TEST_SERVER_LIST
-do
+for SUF in $TEST_SERVER_LIST; do
     eval server_name=\"\$SERVER_NAME_$SUF\"
     server_pid_files="${server_pid_files} ./${server_name}.pid"
 done
@@ -69,12 +68,11 @@
 count=0
 maxcount=4
 while [ $count -le $maxcount ]; do
-    if ls t_server_null_client.sh*.pid > /dev/null 2>&1
-    then
+    if ls t_server_null_client.sh*.pid >/dev/null 2>&1; then
         count=0
         sleep 1
     else
-	count=$(( count + 1))
+        count=$((count + 1))
         sleep 1
     fi
 done
@@ -85,11 +83,10 @@
 # server process does not exit in 15 seconds assume it never will, move on and
 # hope for the best.
 echo "Waiting for servers to exit"
-for PID_FILE in $server_pid_files
-do
+for PID_FILE in $server_pid_files; do
     SERVER_PID=$(cat "${PID_FILE}")
 
-    if [ -z "$SERVER_PID" ] ; then
+    if [ -z "$SERVER_PID" ]; then
         echo "WARNING: could not kill server ${PID_FILE}!"
         continue
     fi
@@ -99,17 +96,16 @@
 
     count=0
     maxcount=75
-    while [ $count -le $maxcount ]
-    do
-        $RUN_SUDO kill -0 "${SERVER_PID}" 2> /dev/null || break
-        count=$(( count + 1))
+    while [ $count -le $maxcount ]; do
+        $RUN_SUDO kill -0 "${SERVER_PID}" 2>/dev/null || break
+        count=$((count + 1))
         sleep 0.2
     done
 
     # If server is still up send a SIGKILL
     if [ $count -ge $maxcount ]; then
         $RUN_SUDO $KILL_EXEC -9 "${SERVER_PID}"
-        SERVER_NAME=$(basename $PID_FILE|cut -d . -f 1)
+        SERVER_NAME=$(basename $PID_FILE | cut -d . -f 1)
         echo "ERROR: had to send SIGKILL to server ${SERVER_NAME} with pid ${SERVER_PID}!"
         echo "Tail of server log:"
         tail -n 20 "${t_server_null_logdir}/${SERVER_NAME}.log"
diff --git a/tests/t_server_null_stress.sh b/tests/t_server_null_stress.sh
index 0bb9452..2fc9fde 100755
--- a/tests/t_server_null_stress.sh
+++ b/tests/t_server_null_stress.sh
@@ -7,8 +7,7 @@
 . ./t_server_null_default.rc
 
 export pid_files=""
-for SUF in $TEST_SERVER_LIST
-do
+for SUF in $TEST_SERVER_LIST; do
     eval server_name=\"\$SERVER_NAME_$SUF\"
     pid_files="${pid_files} ./${server_name}.pid"
 done
@@ -18,16 +17,16 @@
 
 count=0
 while [ $count -lt $ITERATIONS ]; do
-    count=$(( count + 1 ))
-    make check TESTS=t_server_null.sh SUBDIRS= > /dev/null 2>&1
+    count=$((count + 1))
+    make check TESTS=t_server_null.sh SUBDIRS= >/dev/null 2>&1
     retval=$?
 
-    echo "Iteration ${count}: return value ${retval}" >> "${LOG_BASEDIR}/make-check.log"
+    echo "Iteration ${count}: return value ${retval}" >>"${LOG_BASEDIR}/make-check.log"
     if [ $retval -ne 0 ]; then
-	DIR="${LOG_BASEDIR}/make-check-${count}"
+        DIR="${LOG_BASEDIR}/make-check-${count}"
         mkdir -p "${DIR}"
         cp t_server_null*.log "${DIR}/"
         cp test-suite.log "${DIR}/"
-        ps aux|grep openvpn|grep -vE '(suppress|grep)' > "${DIR}/psaux"
+        ps aux | grep openvpn | grep -vE '(suppress|grep)' >"${DIR}/psaux"
     fi
 done
diff --git a/tests/update_t_client_ips.sh b/tests/update_t_client_ips.sh
index 96e3826..777a286 100755
--- a/tests/update_t_client_ips.sh
+++ b/tests/update_t_client_ips.sh
@@ -5,12 +5,12 @@
 
 RC="$TOP_BUILDDIR/t_client_ips.rc"
 
-grep EXPECT_IFCONFIG4_$TESTNUM= $RC > /dev/null 2>&1
+grep EXPECT_IFCONFIG4_$TESTNUM= $RC >/dev/null 2>&1
 if [ $? -ne 0 ]; then
-    echo "EXPECT_IFCONFIG4_$TESTNUM=$ifconfig_local" >> $RC
+    echo "EXPECT_IFCONFIG4_$TESTNUM=$ifconfig_local" >>$RC
 fi
 
-grep EXPECT_IFCONFIG6_$TESTNUM= $RC > /dev/null 2>&1
+grep EXPECT_IFCONFIG6_$TESTNUM= $RC >/dev/null 2>&1
 if [ $? -ne 0 ]; then
-    echo "EXPECT_IFCONFIG6_$TESTNUM=$ifconfig_ipv6_local" >> $RC
+    echo "EXPECT_IFCONFIG6_$TESTNUM=$ifconfig_ipv6_local" >>$RC
 fi


_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Openvpn-devel] [PATCH applied] Re: Reformat all shell-scripts with shfmt
  2026-08-20  9:15 ` [Openvpn-devel] [PATCH v4] " Gert Doering
@ 2026-08-20 10:36   ` Gert Doering
  0 siblings, 0 replies; 13+ messages in thread
From: Gert Doering @ 2026-08-20 10:36 UTC (permalink / raw)
  To: Frank Lichtenheld; +Cc: openvpn-devel

.. and here come the changed shell scripts.  I have stared long and hard
at the changes, and most of them are really harmless ("reduce multiple
blank lines to 1, no whitespace after 'if [ test ]...', "braces for
shell functions on their own line", "reindent inner loop body in 
pipeline constructions").  "git show -w" helps :)

Some are a bit more intrusive ("change '( sleep 5; do_something; )&'
constructs to multiline) but I can't really argue that the new format is 
"actually bad", even if *I* like this more in the compact form.

Your patch has been applied to the master branch.

commit f781227c92a3d1017e9d8a67e83e4465b43edf66
Author: Frank Lichtenheld
Date:   Thu Aug 20 11:15:29 2026 +0200

     Reformat all shell-scripts with shfmt

     Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
     Acked-by: Razvan Cojocaru <razvanc@mailbox.org>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1793
     Message-Id: <20260820091539.4592-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg38547.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering



_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Openvpn-devel] [L] Change in openvpn[master]: Reformat all shell-scripts with shfmt
       [not found] <gerrit.1784305303000.I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f@gerrit.openvpn.net>
                   ` (9 preceding siblings ...)
  2026-08-20  9:15 ` [Openvpn-devel] [PATCH v4] " Gert Doering
@ 2026-08-20 10:36 ` cron2 (Code Review) via Openvpn-devel
  2026-08-20 10:36 ` cron2 (Code Review) via Openvpn-devel
  11 siblings, 0 replies; 13+ messages in thread
From: cron2 (Code Review) via Openvpn-devel @ 2026-08-20 10:36 UTC (permalink / raw)
  To: flichtenheld, plaisthos, razvanc; +Cc: cron2 (Code Review), openvpn-devel


[-- Attachment #1.1: Type: text/plain, Size: 53087 bytes --]

cron2 has uploaded a new patch set (#5) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1793?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by razvanc


Change subject: Reformat all shell-scripts with shfmt
......................................................................

Reformat all shell-scripts with shfmt

According to ./dev-tools/reformat-shell.sh.

Change-Id: I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Razvan Cojocaru <razvanc@mailbox.org>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1793
Message-Id: <20260820091539.4592-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg38547.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
---
M dev-tools/git-pre-commit-format.sh
M dev-tools/run-cppcheck.sh
M dev-tools/update-copyright.sh
M tests/lwip_client_up.sh
M tests/null_client_up.sh
M tests/t_client.sh.in
M tests/t_cltsrv.sh
M tests/t_lpback.sh
M tests/t_net.sh
M tests/t_server_null.sh
M tests/t_server_null_client.sh
M tests/t_server_null_server.sh
M tests/t_server_null_stress.sh
M tests/update_t_client_ips.sh
14 files changed, 386 insertions(+), 385 deletions(-)


  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/93/1793/5

diff --git a/dev-tools/git-pre-commit-format.sh b/dev-tools/git-pre-commit-format.sh
index 9b2ecaf..3507289 100755
--- a/dev-tools/git-pre-commit-format.sh
+++ b/dev-tools/git-pre-commit-format.sh
@@ -26,7 +26,6 @@
 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-
 # git pre-commit hook that runs a stylecheck.
 # Features:
 #  - abort commit when commit does not comply with the style guidelines
@@ -43,12 +42,11 @@
 # exit on error
 set -e

-
 # If called so, install this script as pre-commit hook
-if [ "$1" = "install" ] ; then
+if [ "$1" = "install" ]; then
     TARGET="$(git rev-parse --git-path hooks)/pre-commit"

-    if [ -e "$TARGET" ] ; then
+    if [ -e "$TARGET" ]; then
         printf "$TARGET file exists. Won't overwrite.\n"
         printf "Aborting installation.\n"
         exit 1
@@ -62,18 +60,19 @@
 fi

 # check whether the given file matches any of the set extensions
-matches_extension() {
+matches_extension()
+{
     local filename="$(basename -- "$1")"
     local extension=".${filename##*.}"
     local ext

-    for ext in .c .h ; do [ "$ext" = "$extension" ] && return 0; done
+    for ext in .c .h; do [ "$ext" = "$extension" ] && return 0; done

     return 1
 }

 # necessary check for initial commit
-if git rev-parse --verify HEAD >/dev/null 2>&1 ; then
+if git rev-parse --verify HEAD >/dev/null 2>&1; then
     against=HEAD
 else
     # Initial commit: diff against an empty tree object
@@ -88,8 +87,8 @@

     # Allow to use in parallel with pre-commit
     if [ $(basename "$0") = "pre-commit.legacy" ]; then
-       echo "Skipping clang-format check in favor of pre-commit"
-       exit 0
+        echo "Skipping clang-format check in favor of pre-commit"
+        exit 0
     fi
 else
     TOOL=uncrustify
@@ -98,7 +97,7 @@
     TOOL_CMD="$TOOL_BIN -q -l C -c $UNCRUST_CONFIG"

     # make sure the config file is correctly set
-    if [ ! -f "$UNCRUST_CONFIG" ] ; then
+    if [ ! -f "$UNCRUST_CONFIG" ]; then
         printf "Error: uncrustify config file not found.\n"
         printf "Expected to find it at $UNCRUST_CONFIG.\n"
         printf "Aborting commit.\n"
@@ -106,7 +105,7 @@
     fi
 fi

-if [ -z "$TOOL_BIN" ] ; then
+if [ -z "$TOOL_BIN" ]; then
     printf "Error: $TOOL executable not found.\n"
     printf "Is it installed and in your \$PATH?\n"
     printf "Aborting commit.\n"
@@ -120,44 +119,43 @@
 # create one patch containing all changes to the files
 # sed to remove quotes around the filename, if inserted by the system
 # (done sometimes, if the filename contains special characters, like the quote itself)
-git diff-index --cached --diff-filter=ACMR --name-only $against -- | \
-sed -e 's/^"\(.*\)"$/\1/' | \
-while read file
-do
-    # ignore file if we do check for file extensions and the file
-    # does not match the extensions .c or .h
-    if ! matches_extension "$file"; then
-        continue;
-    fi
+git diff-index --cached --diff-filter=ACMR --name-only $against -- |
+    sed -e 's/^"\(.*\)"$/\1/' |
+    while read file; do
+        # ignore file if we do check for file extensions and the file
+        # does not match the extensions .c or .h
+        if ! matches_extension "$file"; then
+            continue
+        fi

-    # escape special characters in the target filename:
-    # phase 1 (characters escaped in the output diff):
-    #     - '\': backslash needs to be escaped in the output diff
-    #     - '"': quote needs to be escaped in the output diff if present inside
-    #            of the filename, as it used to bracket the entire filename part
-    # phase 2 (characters escaped in the match replacement):
-    #     - '\': backslash needs to be escaped again for sed itself
-    #            (i.e. double escaping after phase 1)
-    #     - '&': would expand to matched string
-    #     - '|': used as sed split char instead of '/'
-    # printf %s particularly important if the filename contains the % character
-    file_escaped_target=$(printf "%s" "$file" | sed -e 's/[\"]/\\&/g' -e 's/[\&|]/\\&/g')
+        # escape special characters in the target filename:
+        # phase 1 (characters escaped in the output diff):
+        #     - '\': backslash needs to be escaped in the output diff
+        #     - '"': quote needs to be escaped in the output diff if present inside
+        #            of the filename, as it used to bracket the entire filename part
+        # phase 2 (characters escaped in the match replacement):
+        #     - '\': backslash needs to be escaped again for sed itself
+        #            (i.e. double escaping after phase 1)
+        #     - '&': would expand to matched string
+        #     - '|': used as sed split char instead of '/'
+        # printf %s particularly important if the filename contains the % character
+        file_escaped_target=$(printf "%s" "$file" | sed -e 's/[\"]/\\&/g' -e 's/[\&|]/\\&/g')

-    # uncrustify our sourcefile, create a patch with diff and append it to our $patch
-    # The sed call is necessary to transform the patch from
-    #    --- - timestamp
-    #    +++ $tmpout timestamp
-    # to both lines working on the same file and having a a/ and b/ prefix.
-    # Else it can not be applied with 'git apply'.
-    git show ":$file" | $TOOL_CMD > "$tmpout"
-    git show ":$file" | diff -u -- - "$tmpout" | \
-        sed -e "1s|--- -|--- \"b/$file_escaped_target\"|" -e "2s|+++ $tmpout|+++ \"a/$file_escaped_target\"|" >> "$patch"
-done
+        # uncrustify our sourcefile, create a patch with diff and append it to our $patch
+        # The sed call is necessary to transform the patch from
+        #    --- - timestamp
+        #    +++ $tmpout timestamp
+        # to both lines working on the same file and having a a/ and b/ prefix.
+        # Else it can not be applied with 'git apply'.
+        git show ":$file" | $TOOL_CMD >"$tmpout"
+        git show ":$file" | diff -u -- - "$tmpout" |
+            sed -e "1s|--- -|--- \"b/$file_escaped_target\"|" -e "2s|+++ $tmpout|+++ \"a/$file_escaped_target\"|" >>"$patch"
+    done

 rm -f "$tmpout"

 # if no patch has been generated all is ok, clean up the file stub and exit
-if [ ! -s "$patch" ] ; then
+if [ ! -s "$patch" ]; then
     rm -f "$patch"
     exit 0
 fi
@@ -165,7 +163,7 @@
 # a patch has been created, notify the user and exit
 printf "Formatting of some code does not follow the project guidelines.\n"

-if [ $(wc -l < $patch) -gt 80 ] ; then
+if [ $(wc -l <$patch) -gt 80 ]; then
     printf "The file $patch contains the necessary fixes.\n"
 else
     printf "Here's the patch that fixes the formatting:\n\n"
diff --git a/dev-tools/run-cppcheck.sh b/dev-tools/run-cppcheck.sh
index 40db33e..a7aa3c4 100755
--- a/dev-tools/run-cppcheck.sh
+++ b/dev-tools/run-cppcheck.sh
@@ -20,24 +20,23 @@
  --check-level=exhaustive --max-configs=10 \
  --error-exitcode=1"

-
 set -x

 mkdir -p "$CPPCHECK_DIR"
 cd "${SOURCE_DIR}"
 cppcheck $COMMON_ARGS $INCLUDE_FLAGS \
-         --platform=unix64 \
-         --library=posix.cfg --library=bsd.cfg --library=gnu.cfg \
-         -U_WIN32 \
-         src/openvpn/ src/compat/ src/plugins/ sample/ \
-         tests/unit_tests/example_test/ tests/unit_tests/openvpn/ \
-         tests/unit_tests/plugins/
+    --platform=unix64 \
+    --library=posix.cfg --library=bsd.cfg --library=gnu.cfg \
+    -U_WIN32 \
+    src/openvpn/ src/compat/ src/plugins/ sample/ \
+    tests/unit_tests/example_test/ tests/unit_tests/openvpn/ \
+    tests/unit_tests/plugins/
 cppcheck $COMMON_ARGS \
-         --platform=win64 \
-         --library=windows.cfg \
-         -D_WIN32 \
-         -UTARGET_LINUX -UTARGET_FREEBSD -UTARGET_OPENBSD -UTARGET_NETBSD \
-         -UTARGET_DARWIN -UTARGET_ANDROID -UTARGET_SOLARIS -UTARGET_DRAGONFLY \
-         -UTARGET_AIX \
-         src/openvpn* src/compat/ \
-         tests/unit_tests/example_test/ tests/unit_tests/openvpn*
+    --platform=win64 \
+    --library=windows.cfg \
+    -D_WIN32 \
+    -UTARGET_LINUX -UTARGET_FREEBSD -UTARGET_OPENBSD -UTARGET_NETBSD \
+    -UTARGET_DARWIN -UTARGET_ANDROID -UTARGET_SOLARIS -UTARGET_DRAGONFLY \
+    -UTARGET_AIX \
+    src/openvpn* src/compat/ \
+    tests/unit_tests/example_test/ tests/unit_tests/openvpn*
diff --git a/dev-tools/update-copyright.sh b/dev-tools/update-copyright.sh
index 96546dd..7ca6002 100755
--- a/dev-tools/update-copyright.sh
+++ b/dev-tools/update-copyright.sh
@@ -34,8 +34,7 @@
 COPY_YEAR="$1"

 cd "$(git rev-parse --show-toplevel)"
-for file in $(git ls-files | grep -v vendor/);
-do
+for file in $(git ls-files | grep -v vendor/); do
     echo -n "Updating $file ..."
     # The first sed operation covers 20xx-20yy copyright lines,
     # The second sed operation changes 20xx -> 20xx-20yy
diff --git a/tests/lwip_client_up.sh b/tests/lwip_client_up.sh
index a6b4d24..b1941a4 100755
--- a/tests/lwip_client_up.sh
+++ b/tests/lwip_client_up.sh
@@ -2,16 +2,17 @@
 #
 # Determine the OpenVPN PID from its pid file. This works reliably even when
 # the OpenVPN process is backgrounded for parallel tests.
-MY_PPID=`cat $pid`
+MY_PPID=$(cat $pid)

 # Add this client's VPN IP and PID to a file. This enables
 # t_server_null_client.sh to kill this OpenVPN client after fping tests have
 # finished.
-echo "$ifconfig_local,$MY_PPID" >> ./$test_name.lwip
+echo "$ifconfig_local,$MY_PPID" >>./$test_name.lwip

 # Wait long enough to allow fping tests to finish. Also ensure that this
 # OpenVPN client is killed even if t_server_null_client.sh failed to do it.
-(sleep 15
-echo "ERROR: t_server_null_client.sh failed to kill OpenVPN client with PID $MY_PPID in test $test_name. Killing it in lwip_client_up.sh."
-kill -15 $MY_PPID
+(
+    sleep 15
+    echo "ERROR: t_server_null_client.sh failed to kill OpenVPN client with PID $MY_PPID in test $test_name. Killing it in lwip_client_up.sh."
+    kill -15 $MY_PPID
 ) &
diff --git a/tests/null_client_up.sh b/tests/null_client_up.sh
index d4df0c6..be339ee 100755
--- a/tests/null_client_up.sh
+++ b/tests/null_client_up.sh
@@ -4,8 +4,11 @@

 # Determine the OpenVPN PID from its pid file. This works reliably even when
 # the OpenVPN process is backgrounded for parallel tests.
-MY_PPID=`cat $pid`
+MY_PPID=$(cat $pid)
 
 # Allow OpenVPN to finish initializing while waiting in the background and then
 # killing the process gracefully.
-(sleep 5 ; kill -15 $MY_PPID) &
+(
+    sleep 5
+    kill -15 $MY_PPID
+) &
diff --git a/tests/t_client.sh.in b/tests/t_client.sh.in
index 2f37845..305441be 100755
--- a/tests/t_client.sh.in
+++ b/tests/t_client.sh.in
@@ -19,9 +19,9 @@
 srcdir="${srcdir:-.}"
 top_builddir="${top_builddir:-..}"
 openvpn="${openvpn:-${top_builddir}/src/openvpn/openvpn}"
-if [ -r "${top_builddir}"/t_client.rc ] ; then
+if [ -r "${top_builddir}"/t_client.rc ]; then
     . "${top_builddir}"/t_client.rc
-elif [ -r "${srcdir}"/t_client.rc ] ; then
+elif [ -r "${srcdir}"/t_client.rc ]; then
     . "${srcdir}"/t_client.rc
 else
     echo "$0: cannot find 't_client.rc' in build dir ('${top_builddir}')" >&2
@@ -32,37 +32,35 @@
 # Check for external dependencies
 FPING="fping"
 FPING6="fping6"
-which fping > /dev/null
+which fping >/dev/null
 if [ $? -ne 0 ]; then
     echo "$0: fping is not available in \$PATH" >&2
     exit "${TCLIENT_SKIP_RC}"
 fi
-which fping6 > /dev/null
+which fping6 >/dev/null
 if [ $? -ne 0 ]; then
     echo "$0: fping6 is not available in \$PATH, assuming fping 4.0 or later" >&2
     FPING="fping -4"
     FPING6="fping -6"
 fi

-KILL_EXEC=`which kill`
+KILL_EXEC=$(which kill)
 if [ $? -ne 0 ]; then
     echo "$0: kill not found in \$PATH" >&2
     exit "${TCLIENT_SKIP_RC}"
 fi

-if [ ! -x "${openvpn}" ]
-then
+if [ ! -x "${openvpn}" ]; then
     echo "no (executable) openvpn binary in current build tree. FAIL." >&2
     exit 1
 fi

-if [ ! -w . ]
-then
+if [ ! -w . ]; then
     echo "current directory is not writable (required for logging). FAIL." >&2
     exit 1
 fi

-if [ -z "$TEST_RUN_LIST" ] ; then
+if [ -z "$TEST_RUN_LIST" ]; then
     echo "TEST_RUN_LIST empty, no tests defined.  SKIP test." >&2
     exit "${TCLIENT_SKIP_RC}"
 fi
@@ -72,16 +70,14 @@

 # make sure we have permissions to run ifconfig/route from OpenVPN
 # can't use "id -u" here - doesn't work on Solaris
-ID=`id`
-if expr "$ID" : "uid=0" >/dev/null
-then :
+ID=$(id)
+if expr "$ID" : "uid=0" >/dev/null; then
+    :
 else
-    if [ "${PREFER_KSU}" -eq 1 ];
-    then
+    if [ "${PREFER_KSU}" -eq 1 ]; then
         # Check if we have a valid kerberos ticket
         klist -l 1>/dev/null 2>/dev/null
-        if [ $? -ne 0 ];
-        then
+        if [ $? -ne 0 ]; then
             # No kerberos ticket found, skip ksu and fallback to RUN_SUDO
             PREFER_KSU=0
             echo "$0: No Kerberos ticket available.  Will not use ksu."
@@ -90,8 +86,7 @@
         fi
     fi

-    if [ -z "$RUN_SUDO" ]
-    then
+    if [ -z "$RUN_SUDO" ]; then
         echo "$0: this test must run be as root, or RUN_SUDO=... " >&2
         echo "      must be set correctly in 't_client.rc'. SKIP." >&2
         exit "${TCLIENT_SKIP_RC}"
@@ -99,20 +94,19 @@
         # We have to use sudo. Make sure that we (hopefully) do not have
         # to ask the users password during the test. This is done to
         # prevent timing issues, e.g. when the waits for openvpn to start
-	if $RUN_SUDO $KILL_EXEC -0 $$
-	then
-	    echo "$0: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
-	else
-	    echo "$0: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
-	    exit "${TCLIENT_SKIP_RC}"
-	fi
+        if $RUN_SUDO $KILL_EXEC -0 $$; then
+            echo "$0: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
+        else
+            echo "$0: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
+            exit "${TCLIENT_SKIP_RC}"
+        fi
     fi
 fi

-LOGDIR=t_client-`hostname`-`date +%Y%m%d-%H%M%S`
+LOGDIR=t_client-$(hostname)-$(date +%Y%m%d-%H%M%S)
 LOGDIR_ABS="$PWD/$LOGDIR"
-if mkdir $LOGDIR
-then :
+if mkdir $LOGDIR; then
+    :
 else
     echo "can't create log directory '$LOGDIR'. FAIL." >&2
     exit 1
@@ -132,21 +126,28 @@
 output_start()
 {
     case $V in
-	0) outbuf="" ;;			# no per-test output at all
-	1) printf "$@\n"			# compact, details only on failure
-           outbuf="\n" ;;
-	*) printf "\n$@\n" ;;		# print all, with a bit formatting
+        0) outbuf="" ;; # no per-test output at all
+        1)
+            printf "$@\n" # compact, details only on failure
+            outbuf="\n"
+            ;;
+        *) printf "\n$@\n" ;; # print all, with a bit formatting
     esac
 }

 output()
 {
-    END_NL="\n"; if [ "X$1" = "X-n" ] ; then END_NL="" ; shift ; fi
+    END_NL="\n"
+    if [ "X$1" = "X-n" ]; then
+        END_NL=""
+        shift
+    fi
     case $V in
-	0) ;;				# no per-test output at all
-	1) outbuf="$outbuf$@${END_NL}"	# print details only on failure
-           ;;
-	*) printf "$@${END_NL}" ;;	# print everything
+        0) ;; # no per-test output at all
+        1)
+            outbuf="$outbuf$@${END_NL}" # print details only on failure
+            ;;
+        *) printf "$@${END_NL}" ;; # print everything
     esac
 }

@@ -154,62 +155,61 @@
 fail()
 {
     output "FAIL: $@\n"
-    fail_count=$(( $fail_count + 1 ))
+    fail_count=$(($fail_count + 1))
 }

 # print "all interface IP addresses" + "all routes"
 # this is higly system dependent...
 get_ifconfig_route()
 {
-    UNAME=`uname -s`
+    UNAME=$(uname -s)
     case $UNAME in
-	Linux)
+        Linux)
             # linux / iproute2? (-> if configure got a path)
-            if [ -n "@IPROUTE@" ]
-            then
+            if [ -n "@IPROUTE@" ]; then
                 echo "-- linux iproute2 --"
-                @IPROUTE@ addr show     | grep -v valid_lft
+                @IPROUTE@ addr show | grep -v valid_lft
                 @IPROUTE@ route show
                 @IPROUTE@ -o -6 route show | grep -v ' cache' | sed -E -e 's/ expires [0-9]*sec//' -e 's/ (mtu|hoplimit|cwnd|ssthresh) [0-9]+//g' -e 's/ (rtt|rttvar) [0-9]+ms//g'
             else
-	        echo "-- linux / ifconfig --"
-	        LANG=C @IFCONFIG@ -a |egrep  "( addr:|encap:)"
-	        LANG=C @NETSTAT@ -rn -4 -6
+                echo "-- linux / ifconfig --"
+                LANG=C @IFCONFIG@ -a | egrep "( addr:|encap:)"
+                LANG=C @NETSTAT@ -rn -4 -6
             fi
             ;;
-	FreeBSD|NetBSD|Darwin)
-	   echo "-- FreeBSD/NetBSD/Darwin [MacOS X] --"
-	   @IFCONFIG@ -a | egrep "(flags=|inet)"
-	   @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
-	   ;;
-	OpenBSD)
-	   echo "-- OpenBSD --"
-	   @IFCONFIG@ -a | egrep "(flags=|inet)" | \
-		sed -e 's/pltime [0-9]*//' -e 's/vltime [0-9]*//'
-	   @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
-	   ;;
-	SunOS)
-	   echo "-- Solaris --"
-	   @IFCONFIG@ -a | egrep "(flags=|inet)"
-	   @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
-	   ;;
-	AIX)
-	   echo "-- AIX --"
-	   @IFCONFIG@ -a | egrep "(flags=|inet)"
-	   @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
-	   ;;
+        FreeBSD | NetBSD | Darwin)
+            echo "-- FreeBSD/NetBSD/Darwin [MacOS X] --"
+            @IFCONFIG@ -a | egrep "(flags=|inet)"
+            @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
+            ;;
+        OpenBSD)
+            echo "-- OpenBSD --"
+            @IFCONFIG@ -a | egrep "(flags=|inet)" |
+                sed -e 's/pltime [0-9]*//' -e 's/vltime [0-9]*//'
+            @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
+            ;;
+        SunOS)
+            echo "-- Solaris --"
+            @IFCONFIG@ -a | egrep "(flags=|inet)"
+            @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
+            ;;
+        AIX)
+            echo "-- AIX --"
+            @IFCONFIG@ -a | egrep "(flags=|inet)"
+            @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
+            ;;
         *)
-           echo "get_ifconfig_route(): no idea how to get info on your OS (`uname -s`).  FAIL." >&2
-           exit 20
-           ;;
+            echo "get_ifconfig_route(): no idea how to get info on your OS ($(uname -s)).  FAIL." >&2
+            exit 20
+            ;;
     esac

     # another round of per-platform information gathering, for DNS info
     # for most of the platforms "cat /etc/resolv.conf" is good enough
     # except Linux and MacOS
     case $UNAME in
-	Linux)
-            if [ -x /usr/bin/resolvectl -a -d /run/systemd/system ] ; then
+        Linux)
+            if [ -x /usr/bin/resolvectl -a -d /run/systemd/system ]; then
                 echo "-- linux resolvectl --"
                 resolvectl status
             else
@@ -217,7 +217,7 @@
                 cat /etc/resolv.conf
             fi
             ;;
-	Darwin)
+        Darwin)
             echo "-- MacOS scutil --dns"
             scutil --dns
             ;;
@@ -234,19 +234,19 @@
 #  arg2: IPv4/IPv6 address that must show up in out of "get_ifconfig_route"
 check_ifconfig()
 {
-    proto=$1 ; shift
+    proto=$1
+    shift
     expect_list="$@"

-    if [ -z "$expect_list" ] ; then return ; fi
-    if [ "$expect_list" = "-" ] ; then return ; fi
+    if [ -z "$expect_list" ]; then return; fi
+    if [ "$expect_list" = "-" ]; then return; fi

-    for expect in $expect_list
-    do
-	if get_ifconfig_route | fgrep "$expect" >/dev/null
-	then :
-	else
-	    fail "check_ifconfig(): expected IPv$proto address '$expect' not found in ifconfig output."
-	fi
+    for expect in $expect_list; do
+        if get_ifconfig_route | fgrep "$expect" >/dev/null; then
+            :
+        else
+            fail "check_ifconfig(): expected IPv$proto address '$expect' not found in ifconfig output."
+        fi
     done
 }

@@ -257,47 +257,48 @@
 #  arg3... -> fping arguments (host list)
 run_ping_tests()
 {
-    proto=$1 ; want=$2 ; shift ; shift
+    proto=$1
+    want=$2
+    shift
+    shift
     targetlist="$@"

     # "no targets" is fine
-    if [ -z "$targetlist" ] ; then return ; fi
+    if [ -z "$targetlist" ]; then return; fi

     case $proto in
-	4) cmd="$FPING" ;;
-	6) cmd="$FPING6" ;;
-	*) echo "internal error in run_ping_tests arg 1: '$proto'" >&2
-	   exit 1 ;;
+        4) cmd="$FPING" ;;
+        6) cmd="$FPING6" ;;
+        *)
+            echo "internal error in run_ping_tests arg 1: '$proto'" >&2
+            exit 1
+            ;;
     esac

     case $want in
-	want_ok)   sizes_list="64 1440 3000" ;;
-	want_fail) sizes_list="64" ;;
+        want_ok) sizes_list="64 1440 3000" ;;
+        want_fail) sizes_list="64" ;;
     esac

-    for bytes in $sizes_list
-    do
-	output "run IPv$proto ping tests ($want), $bytes byte packets..."
+    for bytes in $sizes_list; do
+        output "run IPv$proto ping tests ($want), $bytes byte packets..."

-	echo "$cmd -b $bytes -C 20 -p 250 -q $fping_args $targetlist" >>$LOGDIR/$SUF:fping.out
-	$cmd -b $bytes -C 20 -p 250 -q $fping_args $targetlist >>$LOGDIR/$SUF:fping.out 2>&1
+        echo "$cmd -b $bytes -C 20 -p 250 -q $fping_args $targetlist" >>$LOGDIR/$SUF:fping.out
+        $cmd -b $bytes -C 20 -p 250 -q $fping_args $targetlist >>$LOGDIR/$SUF:fping.out 2>&1

-	# while OpenVPN is running, pings must succeed (want='want_ok')
-	# before OpenVPN is up, pings must NOT succeed (want='want_fail')
+        # while OpenVPN is running, pings must succeed (want='want_ok')
+        # before OpenVPN is up, pings must NOT succeed (want='want_fail')

-	rc=$?
-	if [ $rc = 0 ] 				# all ping OK
-	then
-	    if [ $want = "want_fail" ]		# not what we want
-	    then
-		fail "IPv$proto ping test succeeded, but needs to *fail*."
-	    fi
-	else					# ping failed
-	    if [ $want = "want_ok" ]		# not what we wanted
-	    then
-		fail "IPv$proto ping test ($bytes bytes) failed, but should succeed."
-	    fi
-	fi
+        rc=$?
+        if [ $rc = 0 ]; then                 # all ping OK
+            if [ $want = "want_fail" ]; then # not what we want
+                fail "IPv$proto ping test succeeded, but needs to *fail*."
+            fi
+        else                               # ping failed
+            if [ $want = "want_ok" ]; then # not what we wanted
+                fail "IPv$proto ping test ($bytes bytes) failed, but should succeed."
+            fi
+        fi
     done
 }

@@ -308,8 +309,7 @@
 SUMMARY_SKIP=
 SUMMARY_FAIL=

-for SUF in $TEST_RUN_LIST
-do
+for SUF in $TEST_RUN_LIST; do
     # get config variables
     eval test_prep=\"\$PREPARE_$SUF\"
     eval test_check_skip=\"\$CHECK_SKIP_$SUF\"
@@ -336,11 +336,13 @@

     if [ -n "$test_check_skip" ]; then
         output "check whether we need to skip: '$test_check_skip'"
-        if eval $test_check_skip; then :
+        if eval $test_check_skip; then
+            :
         else
             output "skip check failed, SKIP test $SUF."
-	    SUMMARY_SKIP="$SUMMARY_SKIP $SUF"
-	    printf "$outbuf" ; continue
+            SUMMARY_SKIP="$SUMMARY_SKIP $SUF"
+            printf "$outbuf"
+            continue
         fi
     fi

@@ -355,13 +357,14 @@
     output "\nrun pre-openvpn ping tests - targets must not be reachable..."
     run_ping_tests 4 want_fail "$ping4_hosts"
     run_ping_tests 6 want_fail "$ping6_hosts"
-    if [ "$fail_count" = 0 ] ; then
+    if [ "$fail_count" = 0 ]; then
         output "OK.\n"
     else
-	fail "make sure that ping hosts are ONLY reachable via VPN, SKIP test $SUF."
-	SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
-	exit_code=31
-	printf "$outbuf" ; continue
+        fail "make sure that ping hosts are ONLY reachable via VPN, SKIP test $SUF."
+        SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
+        exit_code=31
+        printf "$outbuf"
+        continue
     fi

     pidfile="$LOGDIR_ABS/openvpn-$SUF.pid"
@@ -376,18 +379,17 @@
     # to $ovpn_init_check times.
     ovpn_init_check=30
     ovpn_init_success=0
-    while [ $ovpn_init_check -gt 0 ];
-    do
-       sleep 1  # Wait for OpenVPN to initialize and have had time to write the pid file
-       grep "Initialization Sequence Completed" $LOGDIR/$SUF:openvpn.log >/dev/null
-       if [ $? -eq 0 ]; then
-           ovpn_init_check=0
-           ovpn_init_success=1
-       fi
-       ovpn_init_check=$(( $ovpn_init_check - 1 ))
+    while [ $ovpn_init_check -gt 0 ]; do
+        sleep 1 # Wait for OpenVPN to initialize and have had time to write the pid file
+        grep "Initialization Sequence Completed" $LOGDIR/$SUF:openvpn.log >/dev/null
+        if [ $? -eq 0 ]; then
+            ovpn_init_check=0
+            ovpn_init_success=1
+        fi
+        ovpn_init_check=$(($ovpn_init_check - 1))
     done

-    opid=`cat $pidfile`
+    opid=$(cat $pidfile)
     if [ -n "$opid" ]; then
         output "  OpenVPN running with PID $opid"
     else
@@ -398,16 +400,17 @@
     if [ $ovpn_init_success -ne 1 -o -z "$opid" ]; then
         output "$0:  OpenVPN did not initialize in a reasonable time"
         if [ -n "$opid" ]; then
-           $RUN_SUDO $KILL_EXEC $opid
+            $RUN_SUDO $KILL_EXEC $opid
         fi
         $RUN_SUDO $KILL_EXEC $sudopid
-	output "tail -5 $SUF:openvpn.log"
-	output "`tail -5 $LOGDIR/$SUF:openvpn.log`"
-	fail "skip rest of sub-tests for test run $SUF."
-	trap - 0 1 2 3 15
-	SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
-	exit_code=30
-	printf "$outbuf" ; continue
+        output "tail -5 $SUF:openvpn.log"
+        output "$(tail -5 $LOGDIR/$SUF:openvpn.log)"
+        fail "skip rest of sub-tests for test run $SUF."
+        trap - 0 1 2 3 15
+        SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
+        exit_code=30
+        printf "$outbuf"
+        continue
     fi

     # make sure openvpn client is terminated in case shell exits
@@ -418,17 +421,16 @@
     output "save ifconfig+route"
     get_ifconfig_route >$LOGDIR/$SUF:ifconfig_route.txt

-    if [ "$expect_ifconfig4" = "-" ] ; then
+    if [ "$expect_ifconfig4" = "-" ]; then
         output "skip ifconfig+route check"
     else
-	output -n "compare pre-openvpn ifconfig+route with current values..."
-	if diff $LOGDIR/$SUF:ifconfig_route_pre.txt \
-		$LOGDIR/$SUF:ifconfig_route.txt >/dev/null
-	then
-	    fail "no differences between ifconfig/route before OpenVPN start and now."
-	else
-	    output " OK!\n"
-	fi
+        output -n "compare pre-openvpn ifconfig+route with current values..."
+        if diff $LOGDIR/$SUF:ifconfig_route_pre.txt \
+            $LOGDIR/$SUF:ifconfig_route.txt >/dev/null; then
+            fail "no differences between ifconfig/route before OpenVPN start and now."
+        else
+            output " OK!\n"
+        fi
     fi

     # post init script needed?
@@ -449,8 +451,8 @@
     $RUN_SUDO $KILL_EXEC $opid
     wait $!
     rc=$?
-    if [ $rc != 0 ] ; then
-	fail "OpenVPN return code $rc, expect 0"
+    if [ $rc != 0 ]; then
+        fail "OpenVPN return code $rc, expect 0"
     fi

     output "\nsave post-openvpn ifconfig + route..."
@@ -458,23 +460,22 @@

     output -n "compare pre- and post-openvpn ifconfig + route..."
     if diff $LOGDIR/$SUF:ifconfig_route_pre.txt \
-	    $LOGDIR/$SUF:ifconfig_route_post.txt >$LOGDIR/$SUF:ifconfig_route_diff.txt
-    then
-	output " OK.\n"
+        $LOGDIR/$SUF:ifconfig_route_post.txt >$LOGDIR/$SUF:ifconfig_route_diff.txt; then
+        output " OK.\n"
     else
-	output "\n\n" "`cat $LOGDIR/$SUF:ifconfig_route_diff.txt`" "\n"
-	fail "differences between pre- and post-ifconfig/route."
+        output "\n\n" "$(cat $LOGDIR/$SUF:ifconfig_route_diff.txt)" "\n"
+        fail "differences between pre- and post-ifconfig/route."
     fi
-    if [ "$fail_count" = 0 ] ; then
+    if [ "$fail_count" = 0 ]; then
         output "test run $SUF: all tests OK.\n"
-	SUMMARY_OK="$SUMMARY_OK $SUF"
+        SUMMARY_OK="$SUMMARY_OK $SUF"
     else
-	if [ "$V" -gt 0 ] ; then
-	    printf "$outbuf"
-	    echo "test run $SUF: $fail_count test failures. FAIL."
+        if [ "$V" -gt 0 ]; then
+            printf "$outbuf"
+            echo "test run $SUF: $fail_count test failures. FAIL."
         fi
-	SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
-	exit_code=30
+        SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
+        exit_code=30
     fi

     if [ -n "$test_cleanup" ]; then
@@ -484,9 +485,9 @@

 done

-if [ -z "$SUMMARY_OK" ] ; then SUMMARY_OK=" none"; fi
-if [ -z "$SUMMARY_SKIP" ] ; then SUMMARY_SKIP=" none"; fi
-if [ -z "$SUMMARY_FAIL" ] ; then SUMMARY_FAIL=" none"; fi
+if [ -z "$SUMMARY_OK" ]; then SUMMARY_OK=" none"; fi
+if [ -z "$SUMMARY_SKIP" ]; then SUMMARY_SKIP=" none"; fi
+if [ -z "$SUMMARY_FAIL" ]; then SUMMARY_FAIL=" none"; fi
 echo "Test sets succeeded:$SUMMARY_OK."
 echo "Test sets skipped:$SUMMARY_SKIP."
 echo "Test sets failed:$SUMMARY_FAIL."
diff --git a/tests/t_cltsrv.sh b/tests/t_cltsrv.sh
index 6b7df65..03c3845 100755
--- a/tests/t_cltsrv.sh
+++ b/tests/t_cltsrv.sh
@@ -24,50 +24,58 @@
 trap "rm -f log.$$ log.$$.signal ; trap 0 ; exit 77" 1 2 15
 trap "rm -f log.$$ log.$$.signal ; exit 1" 0 3
 addopts=
-case `uname -s` in
+case $(uname -s) in
     FreeBSD)
-    # FreeBSD jails map the outgoing IP to the jail IP - we need to
-    # allow the real IP unless we want the test to run forever.
-    if test "`sysctl 2>/dev/null -n security.jail.jailed`" = 1 \
-    || ps -ostate= -p $$ | grep -q J; then
-	addopts="--float"
-	if test "x`ifconfig | grep inet`" = x ; then
-	    echo "###"
-	    echo "### To run the test in a FreeBSD jail, you MUST add an IP alias for the jail's IP."
-	    echo "###"
-	    exit 77
-	fi
-    fi
-    ;;
+        # FreeBSD jails map the outgoing IP to the jail IP - we need to
+        # allow the real IP unless we want the test to run forever.
+        if test "$(sysctl 2>/dev/null -n security.jail.jailed)" = 1 ||
+            ps -ostate= -p $$ | grep -q J; then
+            addopts="--float"
+            if test "x$(ifconfig | grep inet)" = x; then
+                echo "###"
+                echo "### To run the test in a FreeBSD jail, you MUST add an IP alias for the jail's IP."
+                echo "###"
+                exit 77
+            fi
+        fi
+        ;;
 esac

 # make sure that the --down script is executable -- fail (rather than
 # skip) test if it isn't.
 downscript="../tests/t_cltsrv-down.sh"
 root="${top_srcdir}/sample"
-test -x "${root}/${downscript}" || chmod +x "${root}/${downscript}" || { echo >&2 "${root}/${downscript} is not executable, failing." ; exit 1 ; }
+test -x "${root}/${downscript}" || chmod +x "${root}/${downscript}" || {
+    echo >&2 "${root}/${downscript} is not executable, failing."
+    exit 1
+}
 echo "The following test will take about two minutes." >&2
 echo "If the addresses are in use, this test will retry up to two times." >&2

 # go
 success=0
-for i in 1 2 3 ; do
-  set +e
-  (
-  "${openvpn}" --script-security 2 --cd "${root}" ${addopts} --setenv role srv --down "${downscript}" --tls-exit --ping-exit 180 --config "sample-config-files/loopback-server" &
-  "${openvpn}" --script-security 2 --cd "${top_srcdir}/sample" ${addopts} --setenv role clt --down "${downscript}" --tls-exit --ping-exit 180 --config "sample-config-files/loopback-client"
-  ) 3>log.$$.signal >log.$$ 2>&1
-  e1=$?
-  wait $!
-  e2=$?
-  grep 'TCP/UDP: Socket bind failed on local address.*in use' log.$$ >/dev/null && {
-    echo 'address in use, retrying in 150 s'
-    sleep 150
-    continue
-  }
-  grep -v ':inactive$' log.$$.signal >/dev/null && { cat log.$$.signal ; echo ; cat log.$$ ; exit 1 ; }
-  success=1
-  break
+for i in 1 2 3; do
+    set +e
+    (
+        "${openvpn}" --script-security 2 --cd "${root}" ${addopts} --setenv role srv --down "${downscript}" --tls-exit --ping-exit 180 --config "sample-config-files/loopback-server" &
+        "${openvpn}" --script-security 2 --cd "${top_srcdir}/sample" ${addopts} --setenv role clt --down "${downscript}" --tls-exit --ping-exit 180 --config "sample-config-files/loopback-client"
+    ) 3>log.$$.signal >log.$$ 2>&1
+    e1=$?
+    wait $!
+    e2=$?
+    grep 'TCP/UDP: Socket bind failed on local address.*in use' log.$$ >/dev/null && {
+        echo 'address in use, retrying in 150 s'
+        sleep 150
+        continue
+    }
+    grep -v ':inactive$' log.$$.signal >/dev/null && {
+        cat log.$$.signal
+        echo
+        cat log.$$
+        exit 1
+    }
+    success=1
+    break
 done

 set -e
@@ -75,14 +83,14 @@
 # exit code - defaults to 0, PASS
 ec=0

-if [ $success != 1 ] ; then
-  # couldn't run test -- addresses in use, skip test
-  cat log.$$
-  ec=77
-elif [ $e1 != 0 ] || [ $e2 != 0 ] ; then
-  # failure -- fail test
-  cat log.$$
-  ec=1
+if [ $success != 1 ]; then
+    # couldn't run test -- addresses in use, skip test
+    cat log.$$
+    ec=77
+elif [ $e1 != 0 ] || [ $e2 != 0 ]; then
+    # failure -- fail test
+    cat log.$$
+    ec=1
 fi

 rm log.$$ log.$$.signal
diff --git a/tests/t_lpback.sh b/tests/t_lpback.sh
index 6802506..058206f 100755
--- a/tests/t_lpback.sh
+++ b/tests/t_lpback.sh
@@ -37,51 +37,56 @@
 test_start()
 {
     case $V in
-        0) outbuf="" ;;                  # no per-test output at all
-        1) outbuf="$@" ;;                # compact, details only on failure
-        *) printf "$@" ;;                # print all
+        0) outbuf="" ;;   # no per-test output at all
+        1) outbuf="$@" ;; # compact, details only on failure
+        *) printf "$@" ;; # print all
     esac
 }
 test_end()
 {
-    RC=$1 ; LOG=$2
-    if [ $RC != 0 ]
-    then
+    RC=$1
+    LOG=$2
+    if [ $RC != 0 ]; then
         case $V in
-            0) ;;                                # no per-test output
-            1) echo "$outbuf" "FAIL (RC=$RC)"; cat $LOG ;;
-            *) echo "FAIL (RC=$RC)"; cat $LOG ;;
+            0) ;; # no per-test output
+            1)
+                echo "$outbuf" "FAIL (RC=$RC)"
+                cat $LOG
+                ;;
+            *)
+                echo "FAIL (RC=$RC)"
+                cat $LOG
+                ;;
         esac
         e=1
-        tests_failed=$(( $tests_failed + 1 ))
+        tests_failed=$(($tests_failed + 1))
     else
         case $V in
-            0|1) ;;                              # no per-test output for 'OK'
-            *) echo "OK"                         # print all
+            0 | 1) ;;       # no per-test output for 'OK'
+            *) echo "OK" ;; # print all
         esac
-        tests_passed=$(( $tests_passed + 1 ))
+        tests_passed=$(($tests_passed + 1))
     fi
 }

 # if running with V=1, give an indication what test runs now
-if [ "$V" = 1  ] ; then
+if [ "$V" = 1 ]; then
     echo "$0: running with V=$V, only printing test fails"
 fi

-
 # Get list of supported ciphers from openvpn --show-ciphers output
-CIPHERS=$(${openvpn} --show-ciphers | \
-            sed -e '/The following/,/^$/d' -e s'/ .*//' -e '/^[[:space:]]*$/d')
+CIPHERS=$(${openvpn} --show-ciphers |
+    sed -e '/The following/,/^$/d' -e s'/ .*//' -e '/^[[:space:]]*$/d')

 # SK, 2014-06-04: currently the DES-EDE3-CFB1 implementation of OpenSSL is
 # broken (see http://rt.openssl.org/Ticket/Display.html?id=2867), so exclude
 # that cipher from this test.
 # GD, 2014-07-06 so is DES-CFB1
 # GD, 2014-07-06 do not test RC5-* either (fails on NetBSD w/o libcrypto_rc5)
-CIPHERS=$(echo "$CIPHERS" | egrep -v '^(DES-EDE3-CFB1|DES-CFB1|RC5-)' )
+CIPHERS=$(echo "$CIPHERS" | egrep -v '^(DES-EDE3-CFB1|DES-CFB1|RC5-)')

 e=0
-if [ -z "$CIPHERS" ] ; then
+if [ -z "$CIPHERS" ]; then
     echo "'openvpn --show-ciphers' FAILED (empty list)"
     e=1
 fi
@@ -91,10 +96,9 @@
 
 set +e

-for cipher in ${CIPHERS}
-do
+for cipher in ${CIPHERS}; do
     test_start "Testing cipher ${cipher}... "
-    ( "${openvpn}" --test-crypto --cipher ${cipher} ) >log.$$ 2>&1
+    ("${openvpn}" --test-crypto --cipher ${cipher}) >log.$$ 2>&1
     test_end $? log.$$
 done

@@ -121,7 +125,7 @@
     >log.$$ 2>&1
 test_end $? log.$$

-if [ "$V" -ge 1  ] ; then
+if [ "$V" -ge 1 ]; then
     echo "$0: tests passed: $tests_passed  failed: $tests_failed"
 fi

diff --git a/tests/t_net.sh b/tests/t_net.sh
index 8134832..17e028e 100755
--- a/tests/t_net.sh
+++ b/tests/t_net.sh
@@ -9,7 +9,6 @@
 top_builddir="${top_builddir:-..}"
 openvpn="${openvpn:-${top_builddir}/src/openvpn/openvpn}"

-
 # bail out right away on non-linux. NetLink (the object of this test) is only
 # used on Linux, therefore testing other platform is not needed.
 #
@@ -69,7 +68,6 @@
     done
 }

-
 ## execution starts here

 # t_client.rc required only for RUN_SUDO definition
@@ -89,21 +87,18 @@
     exit 77
 fi

-
 # Ensure PREFER_KSU is in a known state
 PREFER_KSU="${PREFER_KSU:-0}"

 # make sure we have permissions to run the networking unit-test
-ID=`id`
-if expr "$ID" : "uid=0" >/dev/null
-then :
+ID=$(id)
+if expr "$ID" : "uid=0" >/dev/null; then
+    :
 else
-    if [ "${PREFER_KSU}" -eq 1 ];
-    then
+    if [ "${PREFER_KSU}" -eq 1 ]; then
         # Check if we have a valid kerberos ticket
         klist -l 1>/dev/null 2>/dev/null
-        if [ $? -ne 0 ];
-        then
+        if [ $? -ne 0 ]; then
             # No kerberos ticket found, skip ksu and fallback to RUN_SUDO
             PREFER_KSU=0
             echo "$0: No Kerberos ticket available.  Will not use ksu."
@@ -112,16 +107,14 @@
         fi
     fi

-    if [ -z "$RUN_SUDO" ]
-    then
+    if [ -z "$RUN_SUDO" ]; then
         echo "$0: no RUN_SUDO=... in t_client.rc or environment, defaulting to 'sudo'." >&2
         echo "      if that does not work, set RUN_SUDO= correctly for your system." >&2
         RUN_SUDO="sudo"
     fi

     # check that we can run the unit-test binary with sudo
-    if $RUN_SUDO $UNIT_TEST test
-    then
+    if $RUN_SUDO $UNIT_TEST test; then
         echo "$0: $RUN_SUDO $UNIT_TEST succeeded, good."
     else
         echo "$0: $RUN_SUDO $UNIT_TEST failed, cannot go on. SKIP." >&2
diff --git a/tests/t_server_null.sh b/tests/t_server_null.sh
index 74ffd52..c633614 100755
--- a/tests/t_server_null.sh
+++ b/tests/t_server_null.sh
@@ -2,7 +2,7 @@
 #
 TSERVER_NULL_SKIP_RC="${TSERVER_NULL_SKIP_RC:-77}"

-if ! [ -r "./t_server_null.rc" ] ; then
+if ! [ -r "./t_server_null.rc" ]; then
     echo "${0}: cannot find './t_server_null.rc. SKIPPING TEST.'" >&2
     exit "${TSERVER_NULL_SKIP_RC}"
 fi
@@ -22,11 +22,10 @@
 # make sure we have permissions to run ifconfig/route from OpenVPN
 # can't use "id -u" here - doesn't work on Solaris
 ID=$(id)
-if expr "$ID" : "uid=0" >/dev/null
-then :
+if expr "$ID" : "uid=0" >/dev/null; then
+    :
 else
-    if [ "${PREFER_KSU}" -eq 1 ];
-    then
+    if [ "${PREFER_KSU}" -eq 1 ]; then
         # Check if we have a valid kerberos ticket
         if klist -l 1>/dev/null 2>/dev/null; then
             RUN_SUDO="ksu -q -e"
@@ -37,26 +36,24 @@
         fi
     fi

-    if [ -z "$RUN_SUDO" ]
-    then
+    if [ -z "$RUN_SUDO" ]; then
         echo "${0}: this test must run be as root, or RUN_SUDO=... " >&2
         echo "      must be set correctly in 't_server_null.rc'. SKIP." >&2
         exit "${TSERVER_NULL_SKIP_RC}"
     else
-	# Run a no-op command with privilege escalation (e.g. sudo) so that
-	# we (hopefully) do not have to ask the users password during the test.
-	if $RUN_SUDO "${KILL_EXEC}" -0 $$
-	then
-	    echo "${0}: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
-	else
-	    echo "${0}: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
-	    exit "${TSERVER_NULL_SKIP_RC}"
-	fi
+        # Run a no-op command with privilege escalation (e.g. sudo) so that
+        # we (hopefully) do not have to ask the users password during the test.
+        if $RUN_SUDO "${KILL_EXEC}" -0 $$; then
+            echo "${0}: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
+        else
+            echo "${0}: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
+            exit "${TSERVER_NULL_SKIP_RC}"
+        fi
     fi
 fi

 srcdir="${srcdir:-.}"
-export t_server_null_logdir=t_server_null-`hostname`-`date +%Y%m%d-%H%M%S`
+export t_server_null_logdir=t_server_null-$(hostname)-$(date +%Y%m%d-%H%M%S)

 # Create directory for server and client logs
 mkdir $t_server_null_logdir
diff --git a/tests/t_server_null_client.sh b/tests/t_server_null_client.sh
index 1745de5..3203cc2 100755
--- a/tests/t_server_null_client.sh
+++ b/tests/t_server_null_client.sh
@@ -1,9 +1,10 @@
 #!/bin/sh

-should_run_test() {
+should_run_test()
+{
     test_name="$1"

-    if echo "$test_name"|grep -q _lwip; then
+    if echo "$test_name" | grep -q _lwip; then
         if [ "$has_lwipovpn" = "no" ]; then
             return 1
         fi
@@ -12,7 +13,8 @@
     return 0
 }

-launch_client() {
+launch_client()
+{
     test_name=$1
     log="${test_name}.log"
     pid="${test_name}.pid"
@@ -30,7 +32,8 @@
         --log "${t_server_null_logdir}/${log}" &
 }

-ping_and_kill() {
+ping_and_kill()
+{
     if fping -q -c 5 $1; then
         echo "PASS: fping lwipovpn client $target"
     else
@@ -46,9 +49,10 @@
     kill -15 $2
 }

-ping_lwip_clients() {
+ping_lwip_clients()
+{
     if [ "$has_lwipovpn" = "yes" ]; then
-        lwip_client_count=$(echo "$lwip_test_names"|wc -w|tr -d " ")
+        lwip_client_count=$(echo "$lwip_test_names" | wc -w | tr -d " ")
     else
         lwip_client_count=0
     fi
@@ -60,10 +64,10 @@
     count=0
     maxcount=10
     while [ $count -le $maxcount ]; do
-        lwip_client_ips=$(cat ./*.lwip 2>/dev/null|wc -l)
+        lwip_client_ips=$(cat ./*.lwip 2>/dev/null | wc -l)
         if [ $lwip_client_ips -lt $lwip_client_count ]; then
             echo "Waiting for LWIP clients to start up ($count/$maxcount)"
-            count=$(( count + 1))
+            count=$((count + 1))
             sleep 1
         else
             echo "$lwip_client_ips/$lwip_client_count LWIP clients up"
@@ -73,8 +77,8 @@

     wait_pids=""
     for line in $(cat ./*.lwip 2>/dev/null); do
-        target_ip=$(echo $line|cut -d "," -f 1)
-        client_pid=$(echo $line|cut -d "," -f 2)
+        target_ip=$(echo $line | cut -d "," -f 1)
+        client_pid=$(echo $line | cut -d "," -f 2)
         ping_and_kill $target_ip $client_pid &
         wait_pids="$wait_pids $!"
     done
@@ -84,7 +88,8 @@
     test -e ./lwip_failed && return 1 || return 0
 }

-wait_for_results() {
+wait_for_results()
+{
     tests_running="yes"

     # Wait a bit to allow an OpenVPN client process to create a pidfile to
@@ -106,12 +111,13 @@
     done
 }

-get_client_test_result() {
+get_client_test_result()
+{
     test_name=$1
     should_pass=$2
     log="${test_name}.log"

-    grep "Initialization Sequence Completed" "${t_server_null_logdir}/${log}" > /dev/null
+    grep "Initialization Sequence Completed" "${t_server_null_logdir}/${log}" >/dev/null
     exit_code=$?

     if [ $exit_code -eq 0 ] && [ "${should_pass}" = "yes" ]; then
@@ -144,7 +150,7 @@
 server_max_wait=15
 while [ $count -lt $server_max_wait ]; do
     servers_up=0
-    server_count=$(echo "$TEST_SERVER_LIST"|wc -w|tr -d " ")
+    server_count=$(echo "$TEST_SERVER_LIST" | wc -w | tr -d " ")

     # We need to trim single-quotes because some shells return quoted values
     # and some don't. Using "set -o posix" which would resolve this problem is
@@ -152,13 +158,13 @@
     #
     # While inactive server configurations may get checked they won't increase
     # the active server count as the processes won't be running.
-    for i in $(set|grep 'SERVER_NAME_'|cut -d "=" -f 2|tr -d "[\']"); do
-        server_pid=$(cat "$i.pid" 2> /dev/null)
-        if [ -z "$server_pid" ] ; then
+    for i in $(set | grep 'SERVER_NAME_' | cut -d "=" -f 2 | tr -d "[\']"); do
+        server_pid=$(cat "$i.pid" 2>/dev/null)
+        if [ -z "$server_pid" ]; then
             continue
         fi
-        if $RUN_SUDO kill -0 $server_pid > /dev/null 2>&1; then
-            servers_up=$(( $servers_up + 1 ))
+        if $RUN_SUDO kill -0 $server_pid >/dev/null 2>&1; then
+            servers_up=$(($servers_up + 1))
         fi
     done

@@ -168,7 +174,7 @@
         retval=0
         break
     else
-        count=$(( count + 1))
+        count=$((count + 1))
         sleep 1
     fi

@@ -199,15 +205,14 @@
 # safe to check the test results.
 test_names=""
 lwip_test_names=""
-for SUF in $TEST_RUN_LIST
-do
+for SUF in $TEST_RUN_LIST; do
     eval test_name=\"\$TEST_NAME_$SUF\"
     eval client_exec=\"\$CLIENT_EXEC_$SUF\"
     eval client_conf=\"\$CLIENT_CONF_$SUF\"

     test_names="${test_names} ${test_name}"

-    if echo "$test_name"|grep -q _lwip; then
+    if echo "$test_name" | grep -q _lwip; then
         lwip_test_names="${lwip_test_names} ${test_name}"
     fi

@@ -219,13 +224,11 @@
 ping_lwip_clients
 retval=$?

-
 # Wait until all OpenVPN clients have exited
 (wait_for_results)

 # Check test results
-for SUF in $TEST_RUN_LIST
-do
+for SUF in $TEST_RUN_LIST; do
     eval test_name=\"\$TEST_NAME_$SUF\"
     eval should_pass=\"\$SHOULD_PASS_$SUF\"

diff --git a/tests/t_server_null_server.sh b/tests/t_server_null_server.sh
index e1775f0..a8d7268 100755
--- a/tests/t_server_null_server.sh
+++ b/tests/t_server_null_server.sh
@@ -1,6 +1,7 @@
 #!/bin/sh

-launch_server() {
+launch_server()
+{
     server_name=$1
     server_exec=$2
     server_conf=$3
@@ -17,10 +18,10 @@

     # Try to launch the server
     $RUN_SUDO "${server_exec}" \
-               $server_conf \
-               --status "${status}" 1 \
-               --writepid "${pid}" \
-               --explicit-exit-notify 3 > "$log" 2>&1 &
+        $server_conf \
+        --status "${status}" 1 \
+        --writepid "${pid}" \
+        --explicit-exit-notify 3 >"$log" 2>&1 &

     sleep 1

@@ -44,8 +45,7 @@
 retval=0

 # Launch test servers
-for SUF in $TEST_SERVER_LIST
-do
+for SUF in $TEST_SERVER_LIST; do
     eval server_name=\"\$SERVER_NAME_$SUF\"
     eval server_exec=\"\$SERVER_EXEC_$SUF\"
     eval server_conf=\"\$SERVER_CONF_$SUF\"
@@ -57,8 +57,7 @@
 # the test run.
 #
 export server_pid_files=""
-for SUF in $TEST_SERVER_LIST
-do
+for SUF in $TEST_SERVER_LIST; do
     eval server_name=\"\$SERVER_NAME_$SUF\"
     server_pid_files="${server_pid_files} ./${server_name}.pid"
 done
@@ -69,12 +68,11 @@
 count=0
 maxcount=4
 while [ $count -le $maxcount ]; do
-    if ls t_server_null_client.sh*.pid > /dev/null 2>&1
-    then
+    if ls t_server_null_client.sh*.pid >/dev/null 2>&1; then
         count=0
         sleep 1
     else
-	count=$(( count + 1))
+        count=$((count + 1))
         sleep 1
     fi
 done
@@ -85,11 +83,10 @@
 # server process does not exit in 15 seconds assume it never will, move on and
 # hope for the best.
 echo "Waiting for servers to exit"
-for PID_FILE in $server_pid_files
-do
+for PID_FILE in $server_pid_files; do
     SERVER_PID=$(cat "${PID_FILE}")

-    if [ -z "$SERVER_PID" ] ; then
+    if [ -z "$SERVER_PID" ]; then
         echo "WARNING: could not kill server ${PID_FILE}!"
         continue
     fi
@@ -99,17 +96,16 @@

     count=0
     maxcount=75
-    while [ $count -le $maxcount ]
-    do
-        $RUN_SUDO kill -0 "${SERVER_PID}" 2> /dev/null || break
-        count=$(( count + 1))
+    while [ $count -le $maxcount ]; do
+        $RUN_SUDO kill -0 "${SERVER_PID}" 2>/dev/null || break
+        count=$((count + 1))
         sleep 0.2
     done

     # If server is still up send a SIGKILL
     if [ $count -ge $maxcount ]; then
         $RUN_SUDO $KILL_EXEC -9 "${SERVER_PID}"
-        SERVER_NAME=$(basename $PID_FILE|cut -d . -f 1)
+        SERVER_NAME=$(basename $PID_FILE | cut -d . -f 1)
         echo "ERROR: had to send SIGKILL to server ${SERVER_NAME} with pid ${SERVER_PID}!"
         echo "Tail of server log:"
         tail -n 20 "${t_server_null_logdir}/${SERVER_NAME}.log"
diff --git a/tests/t_server_null_stress.sh b/tests/t_server_null_stress.sh
index 0bb9452..2fc9fde 100755
--- a/tests/t_server_null_stress.sh
+++ b/tests/t_server_null_stress.sh
@@ -7,8 +7,7 @@
 . ./t_server_null_default.rc

 export pid_files=""
-for SUF in $TEST_SERVER_LIST
-do
+for SUF in $TEST_SERVER_LIST; do
     eval server_name=\"\$SERVER_NAME_$SUF\"
     pid_files="${pid_files} ./${server_name}.pid"
 done
@@ -18,16 +17,16 @@

 count=0
 while [ $count -lt $ITERATIONS ]; do
-    count=$(( count + 1 ))
-    make check TESTS=t_server_null.sh SUBDIRS= > /dev/null 2>&1
+    count=$((count + 1))
+    make check TESTS=t_server_null.sh SUBDIRS= >/dev/null 2>&1
     retval=$?

-    echo "Iteration ${count}: return value ${retval}" >> "${LOG_BASEDIR}/make-check.log"
+    echo "Iteration ${count}: return value ${retval}" >>"${LOG_BASEDIR}/make-check.log"
     if [ $retval -ne 0 ]; then
-	DIR="${LOG_BASEDIR}/make-check-${count}"
+        DIR="${LOG_BASEDIR}/make-check-${count}"
         mkdir -p "${DIR}"
         cp t_server_null*.log "${DIR}/"
         cp test-suite.log "${DIR}/"
-        ps aux|grep openvpn|grep -vE '(suppress|grep)' > "${DIR}/psaux"
+        ps aux | grep openvpn | grep -vE '(suppress|grep)' >"${DIR}/psaux"
     fi
 done
diff --git a/tests/update_t_client_ips.sh b/tests/update_t_client_ips.sh
index 96e3826..777a286 100755
--- a/tests/update_t_client_ips.sh
+++ b/tests/update_t_client_ips.sh
@@ -5,12 +5,12 @@

 RC="$TOP_BUILDDIR/t_client_ips.rc"

-grep EXPECT_IFCONFIG4_$TESTNUM= $RC > /dev/null 2>&1
+grep EXPECT_IFCONFIG4_$TESTNUM= $RC >/dev/null 2>&1
 if [ $? -ne 0 ]; then
-    echo "EXPECT_IFCONFIG4_$TESTNUM=$ifconfig_local" >> $RC
+    echo "EXPECT_IFCONFIG4_$TESTNUM=$ifconfig_local" >>$RC
 fi

-grep EXPECT_IFCONFIG6_$TESTNUM= $RC > /dev/null 2>&1
+grep EXPECT_IFCONFIG6_$TESTNUM= $RC >/dev/null 2>&1
 if [ $? -ne 0 ]; then
-    echo "EXPECT_IFCONFIG6_$TESTNUM=$ifconfig_ipv6_local" >> $RC
+    echo "EXPECT_IFCONFIG6_$TESTNUM=$ifconfig_ipv6_local" >>$RC
 fi

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1793?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f
Gerrit-Change-Number: 1793
Gerrit-PatchSet: 5
Gerrit-Owner: flichtenheld <frank@lichtenheld.com>
Gerrit-Reviewer: plaisthos <arne-openvpn@rfc2549.org>
Gerrit-Reviewer: razvanc <razvanc@mailbox.org>
Gerrit-CC: openvpn-devel <openvpn-devel@lists.sourceforge.net>

[-- Attachment #1.2: Type: text/html, Size: 110317 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Openvpn-devel] [L] Change in openvpn[master]: Reformat all shell-scripts with shfmt
       [not found] <gerrit.1784305303000.I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f@gerrit.openvpn.net>
                   ` (10 preceding siblings ...)
  2026-08-20 10:36 ` [Openvpn-devel] [L] Change in openvpn[master]: " cron2 (Code Review) via Openvpn-devel
@ 2026-08-20 10:36 ` cron2 (Code Review) via Openvpn-devel
  11 siblings, 0 replies; 13+ messages in thread
From: cron2 (Code Review) via Openvpn-devel @ 2026-08-20 10:36 UTC (permalink / raw)
  To: flichtenheld; +Cc: cron2 (Code Review), openvpn-devel, plaisthos


[-- Attachment #1.1: Type: text/plain, Size: 52868 bytes --]

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1793?usp=email )

Change subject: Reformat all shell-scripts with shfmt
......................................................................

Reformat all shell-scripts with shfmt

According to ./dev-tools/reformat-shell.sh.

Change-Id: I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Razvan Cojocaru <razvanc@mailbox.org>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1793
Message-Id: <20260820091539.4592-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg38547.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
---
M dev-tools/git-pre-commit-format.sh
M dev-tools/run-cppcheck.sh
M dev-tools/update-copyright.sh
M tests/lwip_client_up.sh
M tests/null_client_up.sh
M tests/t_client.sh.in
M tests/t_cltsrv.sh
M tests/t_lpback.sh
M tests/t_net.sh
M tests/t_server_null.sh
M tests/t_server_null_client.sh
M tests/t_server_null_server.sh
M tests/t_server_null_stress.sh
M tests/update_t_client_ips.sh
14 files changed, 386 insertions(+), 385 deletions(-)




diff --git a/dev-tools/git-pre-commit-format.sh b/dev-tools/git-pre-commit-format.sh
index 9b2ecaf..3507289 100755
--- a/dev-tools/git-pre-commit-format.sh
+++ b/dev-tools/git-pre-commit-format.sh
@@ -26,7 +26,6 @@
 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-
 # git pre-commit hook that runs a stylecheck.
 # Features:
 #  - abort commit when commit does not comply with the style guidelines
@@ -43,12 +42,11 @@
 # exit on error
 set -e

-
 # If called so, install this script as pre-commit hook
-if [ "$1" = "install" ] ; then
+if [ "$1" = "install" ]; then
     TARGET="$(git rev-parse --git-path hooks)/pre-commit"

-    if [ -e "$TARGET" ] ; then
+    if [ -e "$TARGET" ]; then
         printf "$TARGET file exists. Won't overwrite.\n"
         printf "Aborting installation.\n"
         exit 1
@@ -62,18 +60,19 @@
 fi

 # check whether the given file matches any of the set extensions
-matches_extension() {
+matches_extension()
+{
     local filename="$(basename -- "$1")"
     local extension=".${filename##*.}"
     local ext

-    for ext in .c .h ; do [ "$ext" = "$extension" ] && return 0; done
+    for ext in .c .h; do [ "$ext" = "$extension" ] && return 0; done

     return 1
 }

 # necessary check for initial commit
-if git rev-parse --verify HEAD >/dev/null 2>&1 ; then
+if git rev-parse --verify HEAD >/dev/null 2>&1; then
     against=HEAD
 else
     # Initial commit: diff against an empty tree object
@@ -88,8 +87,8 @@

     # Allow to use in parallel with pre-commit
     if [ $(basename "$0") = "pre-commit.legacy" ]; then
-       echo "Skipping clang-format check in favor of pre-commit"
-       exit 0
+        echo "Skipping clang-format check in favor of pre-commit"
+        exit 0
     fi
 else
     TOOL=uncrustify
@@ -98,7 +97,7 @@
     TOOL_CMD="$TOOL_BIN -q -l C -c $UNCRUST_CONFIG"

     # make sure the config file is correctly set
-    if [ ! -f "$UNCRUST_CONFIG" ] ; then
+    if [ ! -f "$UNCRUST_CONFIG" ]; then
         printf "Error: uncrustify config file not found.\n"
         printf "Expected to find it at $UNCRUST_CONFIG.\n"
         printf "Aborting commit.\n"
@@ -106,7 +105,7 @@
     fi
 fi

-if [ -z "$TOOL_BIN" ] ; then
+if [ -z "$TOOL_BIN" ]; then
     printf "Error: $TOOL executable not found.\n"
     printf "Is it installed and in your \$PATH?\n"
     printf "Aborting commit.\n"
@@ -120,44 +119,43 @@
 # create one patch containing all changes to the files
 # sed to remove quotes around the filename, if inserted by the system
 # (done sometimes, if the filename contains special characters, like the quote itself)
-git diff-index --cached --diff-filter=ACMR --name-only $against -- | \
-sed -e 's/^"\(.*\)"$/\1/' | \
-while read file
-do
-    # ignore file if we do check for file extensions and the file
-    # does not match the extensions .c or .h
-    if ! matches_extension "$file"; then
-        continue;
-    fi
+git diff-index --cached --diff-filter=ACMR --name-only $against -- |
+    sed -e 's/^"\(.*\)"$/\1/' |
+    while read file; do
+        # ignore file if we do check for file extensions and the file
+        # does not match the extensions .c or .h
+        if ! matches_extension "$file"; then
+            continue
+        fi

-    # escape special characters in the target filename:
-    # phase 1 (characters escaped in the output diff):
-    #     - '\': backslash needs to be escaped in the output diff
-    #     - '"': quote needs to be escaped in the output diff if present inside
-    #            of the filename, as it used to bracket the entire filename part
-    # phase 2 (characters escaped in the match replacement):
-    #     - '\': backslash needs to be escaped again for sed itself
-    #            (i.e. double escaping after phase 1)
-    #     - '&': would expand to matched string
-    #     - '|': used as sed split char instead of '/'
-    # printf %s particularly important if the filename contains the % character
-    file_escaped_target=$(printf "%s" "$file" | sed -e 's/[\"]/\\&/g' -e 's/[\&|]/\\&/g')
+        # escape special characters in the target filename:
+        # phase 1 (characters escaped in the output diff):
+        #     - '\': backslash needs to be escaped in the output diff
+        #     - '"': quote needs to be escaped in the output diff if present inside
+        #            of the filename, as it used to bracket the entire filename part
+        # phase 2 (characters escaped in the match replacement):
+        #     - '\': backslash needs to be escaped again for sed itself
+        #            (i.e. double escaping after phase 1)
+        #     - '&': would expand to matched string
+        #     - '|': used as sed split char instead of '/'
+        # printf %s particularly important if the filename contains the % character
+        file_escaped_target=$(printf "%s" "$file" | sed -e 's/[\"]/\\&/g' -e 's/[\&|]/\\&/g')
 
-    # uncrustify our sourcefile, create a patch with diff and append it to our $patch
-    # The sed call is necessary to transform the patch from
-    #    --- - timestamp
-    #    +++ $tmpout timestamp
-    # to both lines working on the same file and having a a/ and b/ prefix.
-    # Else it can not be applied with 'git apply'.
-    git show ":$file" | $TOOL_CMD > "$tmpout"
-    git show ":$file" | diff -u -- - "$tmpout" | \
-        sed -e "1s|--- -|--- \"b/$file_escaped_target\"|" -e "2s|+++ $tmpout|+++ \"a/$file_escaped_target\"|" >> "$patch"
-done
+        # uncrustify our sourcefile, create a patch with diff and append it to our $patch
+        # The sed call is necessary to transform the patch from
+        #    --- - timestamp
+        #    +++ $tmpout timestamp
+        # to both lines working on the same file and having a a/ and b/ prefix.
+        # Else it can not be applied with 'git apply'.
+        git show ":$file" | $TOOL_CMD >"$tmpout"
+        git show ":$file" | diff -u -- - "$tmpout" |
+            sed -e "1s|--- -|--- \"b/$file_escaped_target\"|" -e "2s|+++ $tmpout|+++ \"a/$file_escaped_target\"|" >>"$patch"
+    done

 rm -f "$tmpout"

 # if no patch has been generated all is ok, clean up the file stub and exit
-if [ ! -s "$patch" ] ; then
+if [ ! -s "$patch" ]; then
     rm -f "$patch"
     exit 0
 fi
@@ -165,7 +163,7 @@
 # a patch has been created, notify the user and exit
 printf "Formatting of some code does not follow the project guidelines.\n"

-if [ $(wc -l < $patch) -gt 80 ] ; then
+if [ $(wc -l <$patch) -gt 80 ]; then
     printf "The file $patch contains the necessary fixes.\n"
 else
     printf "Here's the patch that fixes the formatting:\n\n"
diff --git a/dev-tools/run-cppcheck.sh b/dev-tools/run-cppcheck.sh
index 40db33e..a7aa3c4 100755
--- a/dev-tools/run-cppcheck.sh
+++ b/dev-tools/run-cppcheck.sh
@@ -20,24 +20,23 @@
  --check-level=exhaustive --max-configs=10 \
  --error-exitcode=1"

-
 set -x

 mkdir -p "$CPPCHECK_DIR"
 cd "${SOURCE_DIR}"
 cppcheck $COMMON_ARGS $INCLUDE_FLAGS \
-         --platform=unix64 \
-         --library=posix.cfg --library=bsd.cfg --library=gnu.cfg \
-         -U_WIN32 \
-         src/openvpn/ src/compat/ src/plugins/ sample/ \
-         tests/unit_tests/example_test/ tests/unit_tests/openvpn/ \
-         tests/unit_tests/plugins/
+    --platform=unix64 \
+    --library=posix.cfg --library=bsd.cfg --library=gnu.cfg \
+    -U_WIN32 \
+    src/openvpn/ src/compat/ src/plugins/ sample/ \
+    tests/unit_tests/example_test/ tests/unit_tests/openvpn/ \
+    tests/unit_tests/plugins/
 cppcheck $COMMON_ARGS \
-         --platform=win64 \
-         --library=windows.cfg \
-         -D_WIN32 \
-         -UTARGET_LINUX -UTARGET_FREEBSD -UTARGET_OPENBSD -UTARGET_NETBSD \
-         -UTARGET_DARWIN -UTARGET_ANDROID -UTARGET_SOLARIS -UTARGET_DRAGONFLY \
-         -UTARGET_AIX \
-         src/openvpn* src/compat/ \
-         tests/unit_tests/example_test/ tests/unit_tests/openvpn*
+    --platform=win64 \
+    --library=windows.cfg \
+    -D_WIN32 \
+    -UTARGET_LINUX -UTARGET_FREEBSD -UTARGET_OPENBSD -UTARGET_NETBSD \
+    -UTARGET_DARWIN -UTARGET_ANDROID -UTARGET_SOLARIS -UTARGET_DRAGONFLY \
+    -UTARGET_AIX \
+    src/openvpn* src/compat/ \
+    tests/unit_tests/example_test/ tests/unit_tests/openvpn*
diff --git a/dev-tools/update-copyright.sh b/dev-tools/update-copyright.sh
index 96546dd..7ca6002 100755
--- a/dev-tools/update-copyright.sh
+++ b/dev-tools/update-copyright.sh
@@ -34,8 +34,7 @@
 COPY_YEAR="$1"

 cd "$(git rev-parse --show-toplevel)"
-for file in $(git ls-files | grep -v vendor/);
-do
+for file in $(git ls-files | grep -v vendor/); do
     echo -n "Updating $file ..."
     # The first sed operation covers 20xx-20yy copyright lines,
     # The second sed operation changes 20xx -> 20xx-20yy
diff --git a/tests/lwip_client_up.sh b/tests/lwip_client_up.sh
index a6b4d24..b1941a4 100755
--- a/tests/lwip_client_up.sh
+++ b/tests/lwip_client_up.sh
@@ -2,16 +2,17 @@
 #
 # Determine the OpenVPN PID from its pid file. This works reliably even when
 # the OpenVPN process is backgrounded for parallel tests.
-MY_PPID=`cat $pid`
+MY_PPID=$(cat $pid)

 # Add this client's VPN IP and PID to a file. This enables
 # t_server_null_client.sh to kill this OpenVPN client after fping tests have
 # finished.
-echo "$ifconfig_local,$MY_PPID" >> ./$test_name.lwip
+echo "$ifconfig_local,$MY_PPID" >>./$test_name.lwip

 # Wait long enough to allow fping tests to finish. Also ensure that this
 # OpenVPN client is killed even if t_server_null_client.sh failed to do it.
-(sleep 15
-echo "ERROR: t_server_null_client.sh failed to kill OpenVPN client with PID $MY_PPID in test $test_name. Killing it in lwip_client_up.sh."
-kill -15 $MY_PPID
+(
+    sleep 15
+    echo "ERROR: t_server_null_client.sh failed to kill OpenVPN client with PID $MY_PPID in test $test_name. Killing it in lwip_client_up.sh."
+    kill -15 $MY_PPID
 ) &
diff --git a/tests/null_client_up.sh b/tests/null_client_up.sh
index d4df0c6..be339ee 100755
--- a/tests/null_client_up.sh
+++ b/tests/null_client_up.sh
@@ -4,8 +4,11 @@

 # Determine the OpenVPN PID from its pid file. This works reliably even when
 # the OpenVPN process is backgrounded for parallel tests.
-MY_PPID=`cat $pid`
+MY_PPID=$(cat $pid)

 # Allow OpenVPN to finish initializing while waiting in the background and then
 # killing the process gracefully.
-(sleep 5 ; kill -15 $MY_PPID) &
+(
+    sleep 5
+    kill -15 $MY_PPID
+) &
diff --git a/tests/t_client.sh.in b/tests/t_client.sh.in
index 2f37845..305441be 100755
--- a/tests/t_client.sh.in
+++ b/tests/t_client.sh.in
@@ -19,9 +19,9 @@
 srcdir="${srcdir:-.}"
 top_builddir="${top_builddir:-..}"
 openvpn="${openvpn:-${top_builddir}/src/openvpn/openvpn}"
-if [ -r "${top_builddir}"/t_client.rc ] ; then
+if [ -r "${top_builddir}"/t_client.rc ]; then
     . "${top_builddir}"/t_client.rc
-elif [ -r "${srcdir}"/t_client.rc ] ; then
+elif [ -r "${srcdir}"/t_client.rc ]; then
     . "${srcdir}"/t_client.rc
 else
     echo "$0: cannot find 't_client.rc' in build dir ('${top_builddir}')" >&2
@@ -32,37 +32,35 @@
 # Check for external dependencies
 FPING="fping"
 FPING6="fping6"
-which fping > /dev/null
+which fping >/dev/null
 if [ $? -ne 0 ]; then
     echo "$0: fping is not available in \$PATH" >&2
     exit "${TCLIENT_SKIP_RC}"
 fi
-which fping6 > /dev/null
+which fping6 >/dev/null
 if [ $? -ne 0 ]; then
     echo "$0: fping6 is not available in \$PATH, assuming fping 4.0 or later" >&2
     FPING="fping -4"
     FPING6="fping -6"
 fi

-KILL_EXEC=`which kill`
+KILL_EXEC=$(which kill)
 if [ $? -ne 0 ]; then
     echo "$0: kill not found in \$PATH" >&2
     exit "${TCLIENT_SKIP_RC}"
 fi

-if [ ! -x "${openvpn}" ]
-then
+if [ ! -x "${openvpn}" ]; then
     echo "no (executable) openvpn binary in current build tree. FAIL." >&2
     exit 1
 fi

-if [ ! -w . ]
-then
+if [ ! -w . ]; then
     echo "current directory is not writable (required for logging). FAIL." >&2
     exit 1
 fi

-if [ -z "$TEST_RUN_LIST" ] ; then
+if [ -z "$TEST_RUN_LIST" ]; then
     echo "TEST_RUN_LIST empty, no tests defined.  SKIP test." >&2
     exit "${TCLIENT_SKIP_RC}"
 fi
@@ -72,16 +70,14 @@

 # make sure we have permissions to run ifconfig/route from OpenVPN
 # can't use "id -u" here - doesn't work on Solaris
-ID=`id`
-if expr "$ID" : "uid=0" >/dev/null
-then :
+ID=$(id)
+if expr "$ID" : "uid=0" >/dev/null; then
+    :
 else
-    if [ "${PREFER_KSU}" -eq 1 ];
-    then
+    if [ "${PREFER_KSU}" -eq 1 ]; then
         # Check if we have a valid kerberos ticket
         klist -l 1>/dev/null 2>/dev/null
-        if [ $? -ne 0 ];
-        then
+        if [ $? -ne 0 ]; then
             # No kerberos ticket found, skip ksu and fallback to RUN_SUDO
             PREFER_KSU=0
             echo "$0: No Kerberos ticket available.  Will not use ksu."
@@ -90,8 +86,7 @@
         fi
     fi

-    if [ -z "$RUN_SUDO" ]
-    then
+    if [ -z "$RUN_SUDO" ]; then
         echo "$0: this test must run be as root, or RUN_SUDO=... " >&2
         echo "      must be set correctly in 't_client.rc'. SKIP." >&2
         exit "${TCLIENT_SKIP_RC}"
@@ -99,20 +94,19 @@
         # We have to use sudo. Make sure that we (hopefully) do not have
         # to ask the users password during the test. This is done to
         # prevent timing issues, e.g. when the waits for openvpn to start
-	if $RUN_SUDO $KILL_EXEC -0 $$
-	then
-	    echo "$0: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
-	else
-	    echo "$0: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
-	    exit "${TCLIENT_SKIP_RC}"
-	fi
+        if $RUN_SUDO $KILL_EXEC -0 $$; then
+            echo "$0: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
+        else
+            echo "$0: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
+            exit "${TCLIENT_SKIP_RC}"
+        fi
     fi
 fi

-LOGDIR=t_client-`hostname`-`date +%Y%m%d-%H%M%S`
+LOGDIR=t_client-$(hostname)-$(date +%Y%m%d-%H%M%S)
 LOGDIR_ABS="$PWD/$LOGDIR"
-if mkdir $LOGDIR
-then :
+if mkdir $LOGDIR; then
+    :
 else
     echo "can't create log directory '$LOGDIR'. FAIL." >&2
     exit 1
@@ -132,21 +126,28 @@
 output_start()
 {
     case $V in
-	0) outbuf="" ;;			# no per-test output at all
-	1) printf "$@\n"			# compact, details only on failure
-           outbuf="\n" ;;
-	*) printf "\n$@\n" ;;		# print all, with a bit formatting
+        0) outbuf="" ;; # no per-test output at all
+        1)
+            printf "$@\n" # compact, details only on failure
+            outbuf="\n"
+            ;;
+        *) printf "\n$@\n" ;; # print all, with a bit formatting
     esac
 }
 
 output()
 {
-    END_NL="\n"; if [ "X$1" = "X-n" ] ; then END_NL="" ; shift ; fi
+    END_NL="\n"
+    if [ "X$1" = "X-n" ]; then
+        END_NL=""
+        shift
+    fi
     case $V in
-	0) ;;				# no per-test output at all
-	1) outbuf="$outbuf$@${END_NL}"	# print details only on failure
-           ;;
-	*) printf "$@${END_NL}" ;;	# print everything
+        0) ;; # no per-test output at all
+        1)
+            outbuf="$outbuf$@${END_NL}" # print details only on failure
+            ;;
+        *) printf "$@${END_NL}" ;; # print everything
     esac
 }

@@ -154,62 +155,61 @@
 fail()
 {
     output "FAIL: $@\n"
-    fail_count=$(( $fail_count + 1 ))
+    fail_count=$(($fail_count + 1))
 }

 # print "all interface IP addresses" + "all routes"
 # this is higly system dependent...
 get_ifconfig_route()
 {
-    UNAME=`uname -s`
+    UNAME=$(uname -s)
     case $UNAME in
-	Linux)
+        Linux)
             # linux / iproute2? (-> if configure got a path)
-            if [ -n "@IPROUTE@" ]
-            then
+            if [ -n "@IPROUTE@" ]; then
                 echo "-- linux iproute2 --"
-                @IPROUTE@ addr show     | grep -v valid_lft
+                @IPROUTE@ addr show | grep -v valid_lft
                 @IPROUTE@ route show
                 @IPROUTE@ -o -6 route show | grep -v ' cache' | sed -E -e 's/ expires [0-9]*sec//' -e 's/ (mtu|hoplimit|cwnd|ssthresh) [0-9]+//g' -e 's/ (rtt|rttvar) [0-9]+ms//g'
             else
-	        echo "-- linux / ifconfig --"
-	        LANG=C @IFCONFIG@ -a |egrep  "( addr:|encap:)"
-	        LANG=C @NETSTAT@ -rn -4 -6
+                echo "-- linux / ifconfig --"
+                LANG=C @IFCONFIG@ -a | egrep "( addr:|encap:)"
+                LANG=C @NETSTAT@ -rn -4 -6
             fi
             ;;
-	FreeBSD|NetBSD|Darwin)
-	   echo "-- FreeBSD/NetBSD/Darwin [MacOS X] --"
-	   @IFCONFIG@ -a | egrep "(flags=|inet)"
-	   @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
-	   ;;
-	OpenBSD)
-	   echo "-- OpenBSD --"
-	   @IFCONFIG@ -a | egrep "(flags=|inet)" | \
-		sed -e 's/pltime [0-9]*//' -e 's/vltime [0-9]*//'
-	   @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
-	   ;;
-	SunOS)
-	   echo "-- Solaris --"
-	   @IFCONFIG@ -a | egrep "(flags=|inet)"
-	   @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
-	   ;;
-	AIX)
-	   echo "-- AIX --"
-	   @IFCONFIG@ -a | egrep "(flags=|inet)"
-	   @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
-	   ;;
+        FreeBSD | NetBSD | Darwin)
+            echo "-- FreeBSD/NetBSD/Darwin [MacOS X] --"
+            @IFCONFIG@ -a | egrep "(flags=|inet)"
+            @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
+            ;;
+        OpenBSD)
+            echo "-- OpenBSD --"
+            @IFCONFIG@ -a | egrep "(flags=|inet)" |
+                sed -e 's/pltime [0-9]*//' -e 's/vltime [0-9]*//'
+            @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
+            ;;
+        SunOS)
+            echo "-- Solaris --"
+            @IFCONFIG@ -a | egrep "(flags=|inet)"
+            @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
+            ;;
+        AIX)
+            echo "-- AIX --"
+            @IFCONFIG@ -a | egrep "(flags=|inet)"
+            @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
+            ;;
         *)
-           echo "get_ifconfig_route(): no idea how to get info on your OS (`uname -s`).  FAIL." >&2
-           exit 20
-           ;;
+            echo "get_ifconfig_route(): no idea how to get info on your OS ($(uname -s)).  FAIL." >&2
+            exit 20
+            ;;
     esac

     # another round of per-platform information gathering, for DNS info
     # for most of the platforms "cat /etc/resolv.conf" is good enough
     # except Linux and MacOS
     case $UNAME in
-	Linux)
-            if [ -x /usr/bin/resolvectl -a -d /run/systemd/system ] ; then
+        Linux)
+            if [ -x /usr/bin/resolvectl -a -d /run/systemd/system ]; then
                 echo "-- linux resolvectl --"
                 resolvectl status
             else
@@ -217,7 +217,7 @@
                 cat /etc/resolv.conf
             fi
             ;;
-	Darwin)
+        Darwin)
             echo "-- MacOS scutil --dns"
             scutil --dns
             ;;
@@ -234,19 +234,19 @@
 #  arg2: IPv4/IPv6 address that must show up in out of "get_ifconfig_route"
 check_ifconfig()
 {
-    proto=$1 ; shift
+    proto=$1
+    shift
     expect_list="$@"

-    if [ -z "$expect_list" ] ; then return ; fi
-    if [ "$expect_list" = "-" ] ; then return ; fi
+    if [ -z "$expect_list" ]; then return; fi
+    if [ "$expect_list" = "-" ]; then return; fi

-    for expect in $expect_list
-    do
-	if get_ifconfig_route | fgrep "$expect" >/dev/null
-	then :
-	else
-	    fail "check_ifconfig(): expected IPv$proto address '$expect' not found in ifconfig output."
-	fi
+    for expect in $expect_list; do
+        if get_ifconfig_route | fgrep "$expect" >/dev/null; then
+            :
+        else
+            fail "check_ifconfig(): expected IPv$proto address '$expect' not found in ifconfig output."
+        fi
     done
 }

@@ -257,47 +257,48 @@
 #  arg3... -> fping arguments (host list)
 run_ping_tests()
 {
-    proto=$1 ; want=$2 ; shift ; shift
+    proto=$1
+    want=$2
+    shift
+    shift
     targetlist="$@"

     # "no targets" is fine
-    if [ -z "$targetlist" ] ; then return ; fi
+    if [ -z "$targetlist" ]; then return; fi

     case $proto in
-	4) cmd="$FPING" ;;
-	6) cmd="$FPING6" ;;
-	*) echo "internal error in run_ping_tests arg 1: '$proto'" >&2
-	   exit 1 ;;
+        4) cmd="$FPING" ;;
+        6) cmd="$FPING6" ;;
+        *)
+            echo "internal error in run_ping_tests arg 1: '$proto'" >&2
+            exit 1
+            ;;
     esac

     case $want in
-	want_ok)   sizes_list="64 1440 3000" ;;
-	want_fail) sizes_list="64" ;;
+        want_ok) sizes_list="64 1440 3000" ;;
+        want_fail) sizes_list="64" ;;
     esac

-    for bytes in $sizes_list
-    do
-	output "run IPv$proto ping tests ($want), $bytes byte packets..."
+    for bytes in $sizes_list; do
+        output "run IPv$proto ping tests ($want), $bytes byte packets..."

-	echo "$cmd -b $bytes -C 20 -p 250 -q $fping_args $targetlist" >>$LOGDIR/$SUF:fping.out
-	$cmd -b $bytes -C 20 -p 250 -q $fping_args $targetlist >>$LOGDIR/$SUF:fping.out 2>&1
+        echo "$cmd -b $bytes -C 20 -p 250 -q $fping_args $targetlist" >>$LOGDIR/$SUF:fping.out
+        $cmd -b $bytes -C 20 -p 250 -q $fping_args $targetlist >>$LOGDIR/$SUF:fping.out 2>&1

-	# while OpenVPN is running, pings must succeed (want='want_ok')
-	# before OpenVPN is up, pings must NOT succeed (want='want_fail')
+        # while OpenVPN is running, pings must succeed (want='want_ok')
+        # before OpenVPN is up, pings must NOT succeed (want='want_fail')

-	rc=$?
-	if [ $rc = 0 ] 				# all ping OK
-	then
-	    if [ $want = "want_fail" ]		# not what we want
-	    then
-		fail "IPv$proto ping test succeeded, but needs to *fail*."
-	    fi
-	else					# ping failed
-	    if [ $want = "want_ok" ]		# not what we wanted
-	    then
-		fail "IPv$proto ping test ($bytes bytes) failed, but should succeed."
-	    fi
-	fi
+        rc=$?
+        if [ $rc = 0 ]; then                 # all ping OK
+            if [ $want = "want_fail" ]; then # not what we want
+                fail "IPv$proto ping test succeeded, but needs to *fail*."
+            fi
+        else                               # ping failed
+            if [ $want = "want_ok" ]; then # not what we wanted
+                fail "IPv$proto ping test ($bytes bytes) failed, but should succeed."
+            fi
+        fi
     done
 }

@@ -308,8 +309,7 @@
 SUMMARY_SKIP=
 SUMMARY_FAIL=

-for SUF in $TEST_RUN_LIST
-do
+for SUF in $TEST_RUN_LIST; do
     # get config variables
     eval test_prep=\"\$PREPARE_$SUF\"
     eval test_check_skip=\"\$CHECK_SKIP_$SUF\"
@@ -336,11 +336,13 @@

     if [ -n "$test_check_skip" ]; then
         output "check whether we need to skip: '$test_check_skip'"
-        if eval $test_check_skip; then :
+        if eval $test_check_skip; then
+            :
         else
             output "skip check failed, SKIP test $SUF."
-	    SUMMARY_SKIP="$SUMMARY_SKIP $SUF"
-	    printf "$outbuf" ; continue
+            SUMMARY_SKIP="$SUMMARY_SKIP $SUF"
+            printf "$outbuf"
+            continue
         fi
     fi

@@ -355,13 +357,14 @@
     output "\nrun pre-openvpn ping tests - targets must not be reachable..."
     run_ping_tests 4 want_fail "$ping4_hosts"
     run_ping_tests 6 want_fail "$ping6_hosts"
-    if [ "$fail_count" = 0 ] ; then
+    if [ "$fail_count" = 0 ]; then
         output "OK.\n"
     else
-	fail "make sure that ping hosts are ONLY reachable via VPN, SKIP test $SUF."
-	SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
-	exit_code=31
-	printf "$outbuf" ; continue
+        fail "make sure that ping hosts are ONLY reachable via VPN, SKIP test $SUF."
+        SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
+        exit_code=31
+        printf "$outbuf"
+        continue
     fi

     pidfile="$LOGDIR_ABS/openvpn-$SUF.pid"
@@ -376,18 +379,17 @@
     # to $ovpn_init_check times.
     ovpn_init_check=30
     ovpn_init_success=0
-    while [ $ovpn_init_check -gt 0 ];
-    do
-       sleep 1  # Wait for OpenVPN to initialize and have had time to write the pid file
-       grep "Initialization Sequence Completed" $LOGDIR/$SUF:openvpn.log >/dev/null
-       if [ $? -eq 0 ]; then
-           ovpn_init_check=0
-           ovpn_init_success=1
-       fi
-       ovpn_init_check=$(( $ovpn_init_check - 1 ))
+    while [ $ovpn_init_check -gt 0 ]; do
+        sleep 1 # Wait for OpenVPN to initialize and have had time to write the pid file
+        grep "Initialization Sequence Completed" $LOGDIR/$SUF:openvpn.log >/dev/null
+        if [ $? -eq 0 ]; then
+            ovpn_init_check=0
+            ovpn_init_success=1
+        fi
+        ovpn_init_check=$(($ovpn_init_check - 1))
     done

-    opid=`cat $pidfile`
+    opid=$(cat $pidfile)
     if [ -n "$opid" ]; then
         output "  OpenVPN running with PID $opid"
     else
@@ -398,16 +400,17 @@
     if [ $ovpn_init_success -ne 1 -o -z "$opid" ]; then
         output "$0:  OpenVPN did not initialize in a reasonable time"
         if [ -n "$opid" ]; then
-           $RUN_SUDO $KILL_EXEC $opid
+            $RUN_SUDO $KILL_EXEC $opid
         fi
         $RUN_SUDO $KILL_EXEC $sudopid
-	output "tail -5 $SUF:openvpn.log"
-	output "`tail -5 $LOGDIR/$SUF:openvpn.log`"
-	fail "skip rest of sub-tests for test run $SUF."
-	trap - 0 1 2 3 15
-	SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
-	exit_code=30
-	printf "$outbuf" ; continue
+        output "tail -5 $SUF:openvpn.log"
+        output "$(tail -5 $LOGDIR/$SUF:openvpn.log)"
+        fail "skip rest of sub-tests for test run $SUF."
+        trap - 0 1 2 3 15
+        SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
+        exit_code=30
+        printf "$outbuf"
+        continue
     fi

     # make sure openvpn client is terminated in case shell exits
@@ -418,17 +421,16 @@
     output "save ifconfig+route"
     get_ifconfig_route >$LOGDIR/$SUF:ifconfig_route.txt

-    if [ "$expect_ifconfig4" = "-" ] ; then
+    if [ "$expect_ifconfig4" = "-" ]; then
         output "skip ifconfig+route check"
     else
-	output -n "compare pre-openvpn ifconfig+route with current values..."
-	if diff $LOGDIR/$SUF:ifconfig_route_pre.txt \
-		$LOGDIR/$SUF:ifconfig_route.txt >/dev/null
-	then
-	    fail "no differences between ifconfig/route before OpenVPN start and now."
-	else
-	    output " OK!\n"
-	fi
+        output -n "compare pre-openvpn ifconfig+route with current values..."
+        if diff $LOGDIR/$SUF:ifconfig_route_pre.txt \
+            $LOGDIR/$SUF:ifconfig_route.txt >/dev/null; then
+            fail "no differences between ifconfig/route before OpenVPN start and now."
+        else
+            output " OK!\n"
+        fi
     fi

     # post init script needed?
@@ -449,8 +451,8 @@
     $RUN_SUDO $KILL_EXEC $opid
     wait $!
     rc=$?
-    if [ $rc != 0 ] ; then
-	fail "OpenVPN return code $rc, expect 0"
+    if [ $rc != 0 ]; then
+        fail "OpenVPN return code $rc, expect 0"
     fi

     output "\nsave post-openvpn ifconfig + route..."
@@ -458,23 +460,22 @@

     output -n "compare pre- and post-openvpn ifconfig + route..."
     if diff $LOGDIR/$SUF:ifconfig_route_pre.txt \
-	    $LOGDIR/$SUF:ifconfig_route_post.txt >$LOGDIR/$SUF:ifconfig_route_diff.txt
-    then
-	output " OK.\n"
+        $LOGDIR/$SUF:ifconfig_route_post.txt >$LOGDIR/$SUF:ifconfig_route_diff.txt; then
+        output " OK.\n"
     else
-	output "\n\n" "`cat $LOGDIR/$SUF:ifconfig_route_diff.txt`" "\n"
-	fail "differences between pre- and post-ifconfig/route."
+        output "\n\n" "$(cat $LOGDIR/$SUF:ifconfig_route_diff.txt)" "\n"
+        fail "differences between pre- and post-ifconfig/route."
     fi
-    if [ "$fail_count" = 0 ] ; then
+    if [ "$fail_count" = 0 ]; then
         output "test run $SUF: all tests OK.\n"
-	SUMMARY_OK="$SUMMARY_OK $SUF"
+        SUMMARY_OK="$SUMMARY_OK $SUF"
     else
-	if [ "$V" -gt 0 ] ; then
-	    printf "$outbuf"
-	    echo "test run $SUF: $fail_count test failures. FAIL."
+        if [ "$V" -gt 0 ]; then
+            printf "$outbuf"
+            echo "test run $SUF: $fail_count test failures. FAIL."
         fi
-	SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
-	exit_code=30
+        SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
+        exit_code=30
     fi

     if [ -n "$test_cleanup" ]; then
@@ -484,9 +485,9 @@

 done

-if [ -z "$SUMMARY_OK" ] ; then SUMMARY_OK=" none"; fi
-if [ -z "$SUMMARY_SKIP" ] ; then SUMMARY_SKIP=" none"; fi
-if [ -z "$SUMMARY_FAIL" ] ; then SUMMARY_FAIL=" none"; fi
+if [ -z "$SUMMARY_OK" ]; then SUMMARY_OK=" none"; fi
+if [ -z "$SUMMARY_SKIP" ]; then SUMMARY_SKIP=" none"; fi
+if [ -z "$SUMMARY_FAIL" ]; then SUMMARY_FAIL=" none"; fi
 echo "Test sets succeeded:$SUMMARY_OK."
 echo "Test sets skipped:$SUMMARY_SKIP."
 echo "Test sets failed:$SUMMARY_FAIL."
diff --git a/tests/t_cltsrv.sh b/tests/t_cltsrv.sh
index 6b7df65..03c3845 100755
--- a/tests/t_cltsrv.sh
+++ b/tests/t_cltsrv.sh
@@ -24,50 +24,58 @@
 trap "rm -f log.$$ log.$$.signal ; trap 0 ; exit 77" 1 2 15
 trap "rm -f log.$$ log.$$.signal ; exit 1" 0 3
 addopts=
-case `uname -s` in
+case $(uname -s) in
     FreeBSD)
-    # FreeBSD jails map the outgoing IP to the jail IP - we need to
-    # allow the real IP unless we want the test to run forever.
-    if test "`sysctl 2>/dev/null -n security.jail.jailed`" = 1 \
-    || ps -ostate= -p $$ | grep -q J; then
-	addopts="--float"
-	if test "x`ifconfig | grep inet`" = x ; then
-	    echo "###"
-	    echo "### To run the test in a FreeBSD jail, you MUST add an IP alias for the jail's IP."
-	    echo "###"
-	    exit 77
-	fi
-    fi
-    ;;
+        # FreeBSD jails map the outgoing IP to the jail IP - we need to
+        # allow the real IP unless we want the test to run forever.
+        if test "$(sysctl 2>/dev/null -n security.jail.jailed)" = 1 ||
+            ps -ostate= -p $$ | grep -q J; then
+            addopts="--float"
+            if test "x$(ifconfig | grep inet)" = x; then
+                echo "###"
+                echo "### To run the test in a FreeBSD jail, you MUST add an IP alias for the jail's IP."
+                echo "###"
+                exit 77
+            fi
+        fi
+        ;;
 esac

 # make sure that the --down script is executable -- fail (rather than
 # skip) test if it isn't.
 downscript="../tests/t_cltsrv-down.sh"
 root="${top_srcdir}/sample"
-test -x "${root}/${downscript}" || chmod +x "${root}/${downscript}" || { echo >&2 "${root}/${downscript} is not executable, failing." ; exit 1 ; }
+test -x "${root}/${downscript}" || chmod +x "${root}/${downscript}" || {
+    echo >&2 "${root}/${downscript} is not executable, failing."
+    exit 1
+}
 echo "The following test will take about two minutes." >&2
 echo "If the addresses are in use, this test will retry up to two times." >&2

 # go
 success=0
-for i in 1 2 3 ; do
-  set +e
-  (
-  "${openvpn}" --script-security 2 --cd "${root}" ${addopts} --setenv role srv --down "${downscript}" --tls-exit --ping-exit 180 --config "sample-config-files/loopback-server" &
-  "${openvpn}" --script-security 2 --cd "${top_srcdir}/sample" ${addopts} --setenv role clt --down "${downscript}" --tls-exit --ping-exit 180 --config "sample-config-files/loopback-client"
-  ) 3>log.$$.signal >log.$$ 2>&1
-  e1=$?
-  wait $!
-  e2=$?
-  grep 'TCP/UDP: Socket bind failed on local address.*in use' log.$$ >/dev/null && {
-    echo 'address in use, retrying in 150 s'
-    sleep 150
-    continue
-  }
-  grep -v ':inactive$' log.$$.signal >/dev/null && { cat log.$$.signal ; echo ; cat log.$$ ; exit 1 ; }
-  success=1
-  break
+for i in 1 2 3; do
+    set +e
+    (
+        "${openvpn}" --script-security 2 --cd "${root}" ${addopts} --setenv role srv --down "${downscript}" --tls-exit --ping-exit 180 --config "sample-config-files/loopback-server" &
+        "${openvpn}" --script-security 2 --cd "${top_srcdir}/sample" ${addopts} --setenv role clt --down "${downscript}" --tls-exit --ping-exit 180 --config "sample-config-files/loopback-client"
+    ) 3>log.$$.signal >log.$$ 2>&1
+    e1=$?
+    wait $!
+    e2=$?
+    grep 'TCP/UDP: Socket bind failed on local address.*in use' log.$$ >/dev/null && {
+        echo 'address in use, retrying in 150 s'
+        sleep 150
+        continue
+    }
+    grep -v ':inactive$' log.$$.signal >/dev/null && {
+        cat log.$$.signal
+        echo
+        cat log.$$
+        exit 1
+    }
+    success=1
+    break
 done

 set -e
@@ -75,14 +83,14 @@
 # exit code - defaults to 0, PASS
 ec=0

-if [ $success != 1 ] ; then
-  # couldn't run test -- addresses in use, skip test
-  cat log.$$
-  ec=77
-elif [ $e1 != 0 ] || [ $e2 != 0 ] ; then
-  # failure -- fail test
-  cat log.$$
-  ec=1
+if [ $success != 1 ]; then
+    # couldn't run test -- addresses in use, skip test
+    cat log.$$
+    ec=77
+elif [ $e1 != 0 ] || [ $e2 != 0 ]; then
+    # failure -- fail test
+    cat log.$$
+    ec=1
 fi

 rm log.$$ log.$$.signal
diff --git a/tests/t_lpback.sh b/tests/t_lpback.sh
index 6802506..058206f 100755
--- a/tests/t_lpback.sh
+++ b/tests/t_lpback.sh
@@ -37,51 +37,56 @@
 test_start()
 {
     case $V in
-        0) outbuf="" ;;                  # no per-test output at all
-        1) outbuf="$@" ;;                # compact, details only on failure
-        *) printf "$@" ;;                # print all
+        0) outbuf="" ;;   # no per-test output at all
+        1) outbuf="$@" ;; # compact, details only on failure
+        *) printf "$@" ;; # print all
     esac
 }
 test_end()
 {
-    RC=$1 ; LOG=$2
-    if [ $RC != 0 ]
-    then
+    RC=$1
+    LOG=$2
+    if [ $RC != 0 ]; then
         case $V in
-            0) ;;                                # no per-test output
-            1) echo "$outbuf" "FAIL (RC=$RC)"; cat $LOG ;;
-            *) echo "FAIL (RC=$RC)"; cat $LOG ;;
+            0) ;; # no per-test output
+            1)
+                echo "$outbuf" "FAIL (RC=$RC)"
+                cat $LOG
+                ;;
+            *)
+                echo "FAIL (RC=$RC)"
+                cat $LOG
+                ;;
         esac
         e=1
-        tests_failed=$(( $tests_failed + 1 ))
+        tests_failed=$(($tests_failed + 1))
     else
         case $V in
-            0|1) ;;                              # no per-test output for 'OK'
-            *) echo "OK"                         # print all
+            0 | 1) ;;       # no per-test output for 'OK'
+            *) echo "OK" ;; # print all
         esac
-        tests_passed=$(( $tests_passed + 1 ))
+        tests_passed=$(($tests_passed + 1))
     fi
 }

 # if running with V=1, give an indication what test runs now
-if [ "$V" = 1  ] ; then
+if [ "$V" = 1 ]; then
     echo "$0: running with V=$V, only printing test fails"
 fi

-
 # Get list of supported ciphers from openvpn --show-ciphers output
-CIPHERS=$(${openvpn} --show-ciphers | \
-            sed -e '/The following/,/^$/d' -e s'/ .*//' -e '/^[[:space:]]*$/d')
+CIPHERS=$(${openvpn} --show-ciphers |
+    sed -e '/The following/,/^$/d' -e s'/ .*//' -e '/^[[:space:]]*$/d')

 # SK, 2014-06-04: currently the DES-EDE3-CFB1 implementation of OpenSSL is
 # broken (see http://rt.openssl.org/Ticket/Display.html?id=2867), so exclude
 # that cipher from this test.
 # GD, 2014-07-06 so is DES-CFB1
 # GD, 2014-07-06 do not test RC5-* either (fails on NetBSD w/o libcrypto_rc5)
-CIPHERS=$(echo "$CIPHERS" | egrep -v '^(DES-EDE3-CFB1|DES-CFB1|RC5-)' )
+CIPHERS=$(echo "$CIPHERS" | egrep -v '^(DES-EDE3-CFB1|DES-CFB1|RC5-)')
 
 e=0
-if [ -z "$CIPHERS" ] ; then
+if [ -z "$CIPHERS" ]; then
     echo "'openvpn --show-ciphers' FAILED (empty list)"
     e=1
 fi
@@ -91,10 +96,9 @@

 set +e

-for cipher in ${CIPHERS}
-do
+for cipher in ${CIPHERS}; do
     test_start "Testing cipher ${cipher}... "
-    ( "${openvpn}" --test-crypto --cipher ${cipher} ) >log.$$ 2>&1
+    ("${openvpn}" --test-crypto --cipher ${cipher}) >log.$$ 2>&1
     test_end $? log.$$
 done

@@ -121,7 +125,7 @@
     >log.$$ 2>&1
 test_end $? log.$$

-if [ "$V" -ge 1  ] ; then
+if [ "$V" -ge 1 ]; then
     echo "$0: tests passed: $tests_passed  failed: $tests_failed"
 fi

diff --git a/tests/t_net.sh b/tests/t_net.sh
index 8134832..17e028e 100755
--- a/tests/t_net.sh
+++ b/tests/t_net.sh
@@ -9,7 +9,6 @@
 top_builddir="${top_builddir:-..}"
 openvpn="${openvpn:-${top_builddir}/src/openvpn/openvpn}"

-
 # bail out right away on non-linux. NetLink (the object of this test) is only
 # used on Linux, therefore testing other platform is not needed.
 #
@@ -69,7 +68,6 @@
     done
 }

-
 ## execution starts here

 # t_client.rc required only for RUN_SUDO definition
@@ -89,21 +87,18 @@
     exit 77
 fi

-
 # Ensure PREFER_KSU is in a known state
 PREFER_KSU="${PREFER_KSU:-0}"

 # make sure we have permissions to run the networking unit-test
-ID=`id`
-if expr "$ID" : "uid=0" >/dev/null
-then :
+ID=$(id)
+if expr "$ID" : "uid=0" >/dev/null; then
+    :
 else
-    if [ "${PREFER_KSU}" -eq 1 ];
-    then
+    if [ "${PREFER_KSU}" -eq 1 ]; then
         # Check if we have a valid kerberos ticket
         klist -l 1>/dev/null 2>/dev/null
-        if [ $? -ne 0 ];
-        then
+        if [ $? -ne 0 ]; then
             # No kerberos ticket found, skip ksu and fallback to RUN_SUDO
             PREFER_KSU=0
             echo "$0: No Kerberos ticket available.  Will not use ksu."
@@ -112,16 +107,14 @@
         fi
     fi

-    if [ -z "$RUN_SUDO" ]
-    then
+    if [ -z "$RUN_SUDO" ]; then
         echo "$0: no RUN_SUDO=... in t_client.rc or environment, defaulting to 'sudo'." >&2
         echo "      if that does not work, set RUN_SUDO= correctly for your system." >&2
         RUN_SUDO="sudo"
     fi

     # check that we can run the unit-test binary with sudo
-    if $RUN_SUDO $UNIT_TEST test
-    then
+    if $RUN_SUDO $UNIT_TEST test; then
         echo "$0: $RUN_SUDO $UNIT_TEST succeeded, good."
     else
         echo "$0: $RUN_SUDO $UNIT_TEST failed, cannot go on. SKIP." >&2
diff --git a/tests/t_server_null.sh b/tests/t_server_null.sh
index 74ffd52..c633614 100755
--- a/tests/t_server_null.sh
+++ b/tests/t_server_null.sh
@@ -2,7 +2,7 @@
 #
 TSERVER_NULL_SKIP_RC="${TSERVER_NULL_SKIP_RC:-77}"

-if ! [ -r "./t_server_null.rc" ] ; then
+if ! [ -r "./t_server_null.rc" ]; then
     echo "${0}: cannot find './t_server_null.rc. SKIPPING TEST.'" >&2
     exit "${TSERVER_NULL_SKIP_RC}"
 fi
@@ -22,11 +22,10 @@
 # make sure we have permissions to run ifconfig/route from OpenVPN
 # can't use "id -u" here - doesn't work on Solaris
 ID=$(id)
-if expr "$ID" : "uid=0" >/dev/null
-then :
+if expr "$ID" : "uid=0" >/dev/null; then
+    :
 else
-    if [ "${PREFER_KSU}" -eq 1 ];
-    then
+    if [ "${PREFER_KSU}" -eq 1 ]; then
         # Check if we have a valid kerberos ticket
         if klist -l 1>/dev/null 2>/dev/null; then
             RUN_SUDO="ksu -q -e"
@@ -37,26 +36,24 @@
         fi
     fi

-    if [ -z "$RUN_SUDO" ]
-    then
+    if [ -z "$RUN_SUDO" ]; then
         echo "${0}: this test must run be as root, or RUN_SUDO=... " >&2
         echo "      must be set correctly in 't_server_null.rc'. SKIP." >&2
         exit "${TSERVER_NULL_SKIP_RC}"
     else
-	# Run a no-op command with privilege escalation (e.g. sudo) so that
-	# we (hopefully) do not have to ask the users password during the test.
-	if $RUN_SUDO "${KILL_EXEC}" -0 $$
-	then
-	    echo "${0}: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
-	else
-	    echo "${0}: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
-	    exit "${TSERVER_NULL_SKIP_RC}"
-	fi
+        # Run a no-op command with privilege escalation (e.g. sudo) so that
+        # we (hopefully) do not have to ask the users password during the test.
+        if $RUN_SUDO "${KILL_EXEC}" -0 $$; then
+            echo "${0}: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
+        else
+            echo "${0}: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
+            exit "${TSERVER_NULL_SKIP_RC}"
+        fi
     fi
 fi

 srcdir="${srcdir:-.}"
-export t_server_null_logdir=t_server_null-`hostname`-`date +%Y%m%d-%H%M%S`
+export t_server_null_logdir=t_server_null-$(hostname)-$(date +%Y%m%d-%H%M%S)

 # Create directory for server and client logs
 mkdir $t_server_null_logdir
diff --git a/tests/t_server_null_client.sh b/tests/t_server_null_client.sh
index 1745de5..3203cc2 100755
--- a/tests/t_server_null_client.sh
+++ b/tests/t_server_null_client.sh
@@ -1,9 +1,10 @@
 #!/bin/sh

-should_run_test() {
+should_run_test()
+{
     test_name="$1"

-    if echo "$test_name"|grep -q _lwip; then
+    if echo "$test_name" | grep -q _lwip; then
         if [ "$has_lwipovpn" = "no" ]; then
             return 1
         fi
@@ -12,7 +13,8 @@
     return 0
 }

-launch_client() {
+launch_client()
+{
     test_name=$1
     log="${test_name}.log"
     pid="${test_name}.pid"
@@ -30,7 +32,8 @@
         --log "${t_server_null_logdir}/${log}" &
 }

-ping_and_kill() {
+ping_and_kill()
+{
     if fping -q -c 5 $1; then
         echo "PASS: fping lwipovpn client $target"
     else
@@ -46,9 +49,10 @@
     kill -15 $2
 }

-ping_lwip_clients() {
+ping_lwip_clients()
+{
     if [ "$has_lwipovpn" = "yes" ]; then
-        lwip_client_count=$(echo "$lwip_test_names"|wc -w|tr -d " ")
+        lwip_client_count=$(echo "$lwip_test_names" | wc -w | tr -d " ")
     else
         lwip_client_count=0
     fi
@@ -60,10 +64,10 @@
     count=0
     maxcount=10
     while [ $count -le $maxcount ]; do
-        lwip_client_ips=$(cat ./*.lwip 2>/dev/null|wc -l)
+        lwip_client_ips=$(cat ./*.lwip 2>/dev/null | wc -l)
         if [ $lwip_client_ips -lt $lwip_client_count ]; then
             echo "Waiting for LWIP clients to start up ($count/$maxcount)"
-            count=$(( count + 1))
+            count=$((count + 1))
             sleep 1
         else
             echo "$lwip_client_ips/$lwip_client_count LWIP clients up"
@@ -73,8 +77,8 @@

     wait_pids=""
     for line in $(cat ./*.lwip 2>/dev/null); do
-        target_ip=$(echo $line|cut -d "," -f 1)
-        client_pid=$(echo $line|cut -d "," -f 2)
+        target_ip=$(echo $line | cut -d "," -f 1)
+        client_pid=$(echo $line | cut -d "," -f 2)
         ping_and_kill $target_ip $client_pid &
         wait_pids="$wait_pids $!"
     done
@@ -84,7 +88,8 @@
     test -e ./lwip_failed && return 1 || return 0
 }

-wait_for_results() {
+wait_for_results()
+{
     tests_running="yes"

     # Wait a bit to allow an OpenVPN client process to create a pidfile to
@@ -106,12 +111,13 @@
     done
 }

-get_client_test_result() {
+get_client_test_result()
+{
     test_name=$1
     should_pass=$2
     log="${test_name}.log"

-    grep "Initialization Sequence Completed" "${t_server_null_logdir}/${log}" > /dev/null
+    grep "Initialization Sequence Completed" "${t_server_null_logdir}/${log}" >/dev/null
     exit_code=$?

     if [ $exit_code -eq 0 ] && [ "${should_pass}" = "yes" ]; then
@@ -144,7 +150,7 @@
 server_max_wait=15
 while [ $count -lt $server_max_wait ]; do
     servers_up=0
-    server_count=$(echo "$TEST_SERVER_LIST"|wc -w|tr -d " ")
+    server_count=$(echo "$TEST_SERVER_LIST" | wc -w | tr -d " ")

     # We need to trim single-quotes because some shells return quoted values
     # and some don't. Using "set -o posix" which would resolve this problem is
@@ -152,13 +158,13 @@
     #
     # While inactive server configurations may get checked they won't increase
     # the active server count as the processes won't be running.
-    for i in $(set|grep 'SERVER_NAME_'|cut -d "=" -f 2|tr -d "[\']"); do
-        server_pid=$(cat "$i.pid" 2> /dev/null)
-        if [ -z "$server_pid" ] ; then
+    for i in $(set | grep 'SERVER_NAME_' | cut -d "=" -f 2 | tr -d "[\']"); do
+        server_pid=$(cat "$i.pid" 2>/dev/null)
+        if [ -z "$server_pid" ]; then
             continue
         fi
-        if $RUN_SUDO kill -0 $server_pid > /dev/null 2>&1; then
-            servers_up=$(( $servers_up + 1 ))
+        if $RUN_SUDO kill -0 $server_pid >/dev/null 2>&1; then
+            servers_up=$(($servers_up + 1))
         fi
     done

@@ -168,7 +174,7 @@
         retval=0
         break
     else
-        count=$(( count + 1))
+        count=$((count + 1))
         sleep 1
     fi

@@ -199,15 +205,14 @@
 # safe to check the test results.
 test_names=""
 lwip_test_names=""
-for SUF in $TEST_RUN_LIST
-do
+for SUF in $TEST_RUN_LIST; do
     eval test_name=\"\$TEST_NAME_$SUF\"
     eval client_exec=\"\$CLIENT_EXEC_$SUF\"
     eval client_conf=\"\$CLIENT_CONF_$SUF\"

     test_names="${test_names} ${test_name}"

-    if echo "$test_name"|grep -q _lwip; then
+    if echo "$test_name" | grep -q _lwip; then
         lwip_test_names="${lwip_test_names} ${test_name}"
     fi

@@ -219,13 +224,11 @@
 ping_lwip_clients
 retval=$?

-
 # Wait until all OpenVPN clients have exited
 (wait_for_results)

 # Check test results
-for SUF in $TEST_RUN_LIST
-do
+for SUF in $TEST_RUN_LIST; do
     eval test_name=\"\$TEST_NAME_$SUF\"
     eval should_pass=\"\$SHOULD_PASS_$SUF\"

diff --git a/tests/t_server_null_server.sh b/tests/t_server_null_server.sh
index e1775f0..a8d7268 100755
--- a/tests/t_server_null_server.sh
+++ b/tests/t_server_null_server.sh
@@ -1,6 +1,7 @@
 #!/bin/sh

-launch_server() {
+launch_server()
+{
     server_name=$1
     server_exec=$2
     server_conf=$3
@@ -17,10 +18,10 @@

     # Try to launch the server
     $RUN_SUDO "${server_exec}" \
-               $server_conf \
-               --status "${status}" 1 \
-               --writepid "${pid}" \
-               --explicit-exit-notify 3 > "$log" 2>&1 &
+        $server_conf \
+        --status "${status}" 1 \
+        --writepid "${pid}" \
+        --explicit-exit-notify 3 >"$log" 2>&1 &

     sleep 1

@@ -44,8 +45,7 @@
 retval=0

 # Launch test servers
-for SUF in $TEST_SERVER_LIST
-do
+for SUF in $TEST_SERVER_LIST; do
     eval server_name=\"\$SERVER_NAME_$SUF\"
     eval server_exec=\"\$SERVER_EXEC_$SUF\"
     eval server_conf=\"\$SERVER_CONF_$SUF\"
@@ -57,8 +57,7 @@
 # the test run.
 #
 export server_pid_files=""
-for SUF in $TEST_SERVER_LIST
-do
+for SUF in $TEST_SERVER_LIST; do
     eval server_name=\"\$SERVER_NAME_$SUF\"
     server_pid_files="${server_pid_files} ./${server_name}.pid"
 done
@@ -69,12 +68,11 @@
 count=0
 maxcount=4
 while [ $count -le $maxcount ]; do
-    if ls t_server_null_client.sh*.pid > /dev/null 2>&1
-    then
+    if ls t_server_null_client.sh*.pid >/dev/null 2>&1; then
         count=0
         sleep 1
     else
-	count=$(( count + 1))
+        count=$((count + 1))
         sleep 1
     fi
 done
@@ -85,11 +83,10 @@
 # server process does not exit in 15 seconds assume it never will, move on and
 # hope for the best.
 echo "Waiting for servers to exit"
-for PID_FILE in $server_pid_files
-do
+for PID_FILE in $server_pid_files; do
     SERVER_PID=$(cat "${PID_FILE}")

-    if [ -z "$SERVER_PID" ] ; then
+    if [ -z "$SERVER_PID" ]; then
         echo "WARNING: could not kill server ${PID_FILE}!"
         continue
     fi
@@ -99,17 +96,16 @@

     count=0
     maxcount=75
-    while [ $count -le $maxcount ]
-    do
-        $RUN_SUDO kill -0 "${SERVER_PID}" 2> /dev/null || break
-        count=$(( count + 1))
+    while [ $count -le $maxcount ]; do
+        $RUN_SUDO kill -0 "${SERVER_PID}" 2>/dev/null || break
+        count=$((count + 1))
         sleep 0.2
     done

     # If server is still up send a SIGKILL
     if [ $count -ge $maxcount ]; then
         $RUN_SUDO $KILL_EXEC -9 "${SERVER_PID}"
-        SERVER_NAME=$(basename $PID_FILE|cut -d . -f 1)
+        SERVER_NAME=$(basename $PID_FILE | cut -d . -f 1)
         echo "ERROR: had to send SIGKILL to server ${SERVER_NAME} with pid ${SERVER_PID}!"
         echo "Tail of server log:"
         tail -n 20 "${t_server_null_logdir}/${SERVER_NAME}.log"
diff --git a/tests/t_server_null_stress.sh b/tests/t_server_null_stress.sh
index 0bb9452..2fc9fde 100755
--- a/tests/t_server_null_stress.sh
+++ b/tests/t_server_null_stress.sh
@@ -7,8 +7,7 @@
 . ./t_server_null_default.rc

 export pid_files=""
-for SUF in $TEST_SERVER_LIST
-do
+for SUF in $TEST_SERVER_LIST; do
     eval server_name=\"\$SERVER_NAME_$SUF\"
     pid_files="${pid_files} ./${server_name}.pid"
 done
@@ -18,16 +17,16 @@

 count=0
 while [ $count -lt $ITERATIONS ]; do
-    count=$(( count + 1 ))
-    make check TESTS=t_server_null.sh SUBDIRS= > /dev/null 2>&1
+    count=$((count + 1))
+    make check TESTS=t_server_null.sh SUBDIRS= >/dev/null 2>&1
     retval=$?

-    echo "Iteration ${count}: return value ${retval}" >> "${LOG_BASEDIR}/make-check.log"
+    echo "Iteration ${count}: return value ${retval}" >>"${LOG_BASEDIR}/make-check.log"
     if [ $retval -ne 0 ]; then
-	DIR="${LOG_BASEDIR}/make-check-${count}"
+        DIR="${LOG_BASEDIR}/make-check-${count}"
         mkdir -p "${DIR}"
         cp t_server_null*.log "${DIR}/"
         cp test-suite.log "${DIR}/"
-        ps aux|grep openvpn|grep -vE '(suppress|grep)' > "${DIR}/psaux"
+        ps aux | grep openvpn | grep -vE '(suppress|grep)' >"${DIR}/psaux"
     fi
 done
diff --git a/tests/update_t_client_ips.sh b/tests/update_t_client_ips.sh
index 96e3826..777a286 100755
--- a/tests/update_t_client_ips.sh
+++ b/tests/update_t_client_ips.sh
@@ -5,12 +5,12 @@

 RC="$TOP_BUILDDIR/t_client_ips.rc"

-grep EXPECT_IFCONFIG4_$TESTNUM= $RC > /dev/null 2>&1
+grep EXPECT_IFCONFIG4_$TESTNUM= $RC >/dev/null 2>&1
 if [ $? -ne 0 ]; then
-    echo "EXPECT_IFCONFIG4_$TESTNUM=$ifconfig_local" >> $RC
+    echo "EXPECT_IFCONFIG4_$TESTNUM=$ifconfig_local" >>$RC
 fi

-grep EXPECT_IFCONFIG6_$TESTNUM= $RC > /dev/null 2>&1
+grep EXPECT_IFCONFIG6_$TESTNUM= $RC >/dev/null 2>&1
 if [ $? -ne 0 ]; then
-    echo "EXPECT_IFCONFIG6_$TESTNUM=$ifconfig_ipv6_local" >> $RC
+    echo "EXPECT_IFCONFIG6_$TESTNUM=$ifconfig_ipv6_local" >>$RC
 fi

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1793?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f
Gerrit-Change-Number: 1793
Gerrit-PatchSet: 5
Gerrit-Owner: flichtenheld <frank@lichtenheld.com>
Gerrit-Reviewer: plaisthos <arne-openvpn@rfc2549.org>
Gerrit-Reviewer: razvanc <razvanc@mailbox.org>
Gerrit-CC: openvpn-devel <openvpn-devel@lists.sourceforge.net>

[-- Attachment #1.2: Type: text/html, Size: 110057 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-08-20 10:37 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <gerrit.1784305303000.I76cd38fc4f43c2b75ed4ca6b9a5c9ffdbf332a0f@gerrit.openvpn.net>
2026-07-17 16:21 ` [Openvpn-devel] [L] Change in openvpn[master]: Reformat all shell-scripts with shfmt flichtenheld (Code Review) via Openvpn-devel
2026-07-22  7:29 ` plaisthos (Code Review) via Openvpn-devel
2026-07-22 13:11 ` flichtenheld (Code Review) via Openvpn-devel
2026-08-18  6:31 ` razvanc (Code Review) via Openvpn-devel
2026-08-19 11:42 ` flichtenheld (Code Review) via Openvpn-devel
2026-08-19 11:44 ` flichtenheld (Code Review) via Openvpn-devel
2026-08-19 11:48 ` razvanc (Code Review) via Openvpn-devel
2026-08-19 13:18 ` flichtenheld (Code Review) via Openvpn-devel
2026-08-19 13:44 ` razvanc (Code Review) via Openvpn-devel
2026-08-20  9:15 ` [Openvpn-devel] [PATCH v4] " Gert Doering
2026-08-20 10:36   ` [Openvpn-devel] [PATCH applied] " Gert Doering
2026-08-20 10:36 ` [Openvpn-devel] [L] Change in openvpn[master]: " cron2 (Code Review) via Openvpn-devel
2026-08-20 10:36 ` cron2 (Code Review) via Openvpn-devel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.