From b6fd4912d7a61ec1228a1b3edb41fece1c35c57f Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Thu, 21 Mar 2024 17:48:46 +0100 Subject: [PATCH] Fix shellcheck issues Signed-off-by: Jakub Jelen Reviewed-by: Andreas Schneider --- .gitlab-ci/clang-format-check.sh | 4 ++-- .gitlab-ci/git-check-signoff-trailer.sh | 6 +++--- tests/benchmarks/bench1.sh | 11 ++++++----- tests/benchmarks/bench2.sh | 11 ++++++----- tests/pkcs11/setup-softhsm-tokens.sh | 6 +++--- tests/unittests/hello world.sh | 3 ++- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/.gitlab-ci/clang-format-check.sh b/.gitlab-ci/clang-format-check.sh index 1089c969..261918ae 100755 --- a/.gitlab-ci/clang-format-check.sh +++ b/.gitlab-ci/clang-format-check.sh @@ -2,11 +2,11 @@ # Based on Github Action # https://github.com/yshui/git-clang-format-lint -diff=`git-clang-format --diff --commit $CI_MERGE_REQUEST_DIFF_BASE_SHA` +diff=$(git-clang-format --diff --commit "$CI_MERGE_REQUEST_DIFF_BASE_SHA") [ "$diff" = "no modified files to format" ] && exit 0 [ "$diff" = "clang-format did not modify any files" ] && exit 0 printf "You have introduced coding style breakages, suggested changes:\n\n" -echo "$diff" | colordiff +echo "${diff}" | colordiff exit 1 diff --git a/.gitlab-ci/git-check-signoff-trailer.sh b/.gitlab-ci/git-check-signoff-trailer.sh index ef21eeec..e3819662 100755 --- a/.gitlab-ci/git-check-signoff-trailer.sh +++ b/.gitlab-ci/git-check-signoff-trailer.sh @@ -21,12 +21,12 @@ echo -e "${blue}Checking commit range: $CI_COMMIT_RANGE" echo echo -for commit in `git rev-list $CI_COMMIT_RANGE`; do - git show -s --format=%B $commit | grep "^Signed-off-by: " 2>&1 >/dev/null +for commit in $(git rev-list "$CI_COMMIT_RANGE"); do + git show -s --format=%B "$commit" | grep "^Signed-off-by: " >/dev/null 2>&1 ret=$? if [ $ret -eq 1 ]; then echo -e "${red} >>> Missing Signed-off-by trailer in commit $commit" - failed=`expr $failed + 1` + failed=$(("$failed" + 1)) fi done diff --git a/tests/benchmarks/bench1.sh b/tests/benchmarks/bench1.sh index 21b7e6ec..6b3b20f3 100755 --- a/tests/benchmarks/bench1.sh +++ b/tests/benchmarks/bench1.sh @@ -1,13 +1,14 @@ +#!/bin/bash export CIPHER=aes128-cbc export DEST=localhost echo "Upload raw SSH statistics" -echo "local machine: `uname -a`" -echo "Cipher : $CIPHER ; Destination : $DEST (`ssh $DEST uname -a`)" -echo "Local ssh version: `ssh -V 2>&1`" +echo "local machine: $(uname -a)" +echo "Cipher : $CIPHER ; Destination : $DEST ($(ssh $DEST uname -a))" +echo "Local ssh version: $(ssh -V 2>&1)" echo "Ping latency to $DEST": ping -q -c 1 -n $DEST -echo "Destination $DEST SSHD version : `echo | nc $DEST 22 | head -n1`" -echo "ssh login latency :`(time -f user:%U ssh $DEST 'id > /dev/null') 2>&1`" +echo "Destination $DEST SSHD version : $(echo | nc $DEST 22 | head -n1)" +echo "ssh login latency :$( (command time -f user:%U ssh $DEST 'id > /dev/null') 2>&1)" ./generate.py | dd bs=4096 count=100000 | time ssh -c $CIPHER $DEST "dd bs=4096 of=/dev/null" 2>&1 diff --git a/tests/benchmarks/bench2.sh b/tests/benchmarks/bench2.sh index aa42689d..cf240fda 100755 --- a/tests/benchmarks/bench2.sh +++ b/tests/benchmarks/bench2.sh @@ -1,13 +1,14 @@ +#!/bin/bash export CIPHER=aes128-cbc export DEST=localhost echo "Upload raw SSH statistics" -echo "local machine: `uname -a`" -echo "Cipher : $CIPHER ; Destination : $DEST (`ssh $DEST uname -a`)" -echo "Local ssh version: `samplessh -V 2>&1`" +echo "local machine: $(uname -a)" +echo "Cipher : $CIPHER ; Destination : $DEST ($(ssh $DEST uname -a))" +echo "Local ssh version: $(samplessh -V 2>&1)" echo "Ping latency to $DEST": ping -q -c 1 -n $DEST -echo "Destination $DEST SSHD version : `echo | nc $DEST 22 | head -n1`" -echo "ssh login latency :`(time -f user:%U samplessh $DEST 'id > /dev/null') 2>&1`" +echo "Destination $DEST SSHD version : $(echo | nc $DEST 22 | head -n1)" +echo "ssh login latency :$( (command time -f user:%U samplessh $DEST 'id > /dev/null') 2>&1)" ./generate.py | dd bs=4096 count=100000 | strace samplessh -c $CIPHER $DEST "dd bs=4096 of=/dev/null" 2>&1 diff --git a/tests/pkcs11/setup-softhsm-tokens.sh b/tests/pkcs11/setup-softhsm-tokens.sh index bd8e0944..f61c5a67 100755 --- a/tests/pkcs11/setup-softhsm-tokens.sh +++ b/tests/pkcs11/setup-softhsm-tokens.sh @@ -94,8 +94,8 @@ fi # when creating more keys, we need to restart the p11-kit # so it can pick up the new keys if [ -h "$TESTDIR/p11-kit-server.socket" ]; then - kill -9 $(cat $TESTDIR/p11-kit-server.pid) - rm $TESTDIR/p11-kit-server.socket + kill -9 "$(cat "$TESTDIR/p11-kit-server.pid")" + rm "$TESTDIR/p11-kit-server.socket" fi # p11-kit complains if there is no runtime directory @@ -113,7 +113,7 @@ if [ $ret -ne 0 ]; then echo "$out" exit 1 fi -eval $out +eval "$out" # Symlink the p11-kit-server socket to "known place" P11_KIT_SERVER_ADDRESS_PATH=${P11_KIT_SERVER_ADDRESS:10} diff --git a/tests/unittests/hello world.sh b/tests/unittests/hello world.sh index 9a021b4e..8f687028 100755 --- a/tests/unittests/hello world.sh +++ b/tests/unittests/hello world.sh @@ -1 +1,2 @@ -/bin/echo -n $1 2>&1 \ No newline at end of file +#!/bin/sh +printf '%s' "$1" 2>&1