diff mbox series

[meta-networking,2/3] nftables: Fix ShellCheck violations in ptest wrapper script "run-ptest"

Message ID 20240402133400.3347547-2-William.Lyu@windriver.com
State Accepted
Headers show
Series [meta-networking,1/3] nftables: Fix ptest output format issues | expand

Commit Message

Lyu, William April 2, 2024, 1:33 p.m. UTC
From: William Lyu <William.Lyu@windriver.com>

The following ShellCheck violations in "run-ptest" are fixed:
-   line 4:
    SC2164: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
-   line 7:
    SC2086: Double quote to prevent globbing and word splitting.
-   line 9:
    SC2006: Use $(...) notation instead of legacy backticks `...`.
    SC2086: Double quote to prevent globbing and word splitting.
    SC2126: Consider using 'grep -c' instead of 'grep|wc -l'.
-   line 10:
    SC2006: Use $(...) notation instead of legacy backticks `...`.
    SC2086: Double quote to prevent globbing and word splitting.
    SC2126: Consider using 'grep -c' instead of 'grep|wc -l'.
-   line 17:
    SC2086: Double quote to prevent globbing and word splitting.

Signed-off-by: William Lyu <William.Lyu@windriver.com>
---
 .../recipes-filter/nftables/nftables/run-ptest         | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/meta-networking/recipes-filter/nftables/nftables/run-ptest b/meta-networking/recipes-filter/nftables/nftables/run-ptest
index 3217c743d..363a1ee25 100644
--- a/meta-networking/recipes-filter/nftables/nftables/run-ptest
+++ b/meta-networking/recipes-filter/nftables/nftables/run-ptest
@@ -1,17 +1,17 @@ 
 #!/bin/sh
 
 NFTABLESLIB=@libdir@/nftables
-cd ${NFTABLESLIB}/ptest
+cd ${NFTABLESLIB}/ptest || exit 1
 
 LOG="${NFTABLESLIB}/ptest/nftables_ptest_$(date +%Y%m%d-%H%M%S).log"
-tests/shell/run-tests.sh -v | sed -E '/I: \[OK\]/ s/^/PASS: / ; /W: \[(CHK DUMP|VALGRIND|TAINTED|DUMP FAIL|FAILED)\]/ s/^/FAIL: /' | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" | tee -a ${LOG}
+tests/shell/run-tests.sh -v | sed -E '/I: \[OK\]/ s/^/PASS: / ; /W: \[(CHK DUMP|VALGRIND|TAINTED|DUMP FAIL|FAILED)\]/ s/^/FAIL: /' | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" | tee -a "${LOG}"
 
-passed=`grep PASS: ${LOG}|wc -l`
-failed=`grep FAIL: ${LOG}|wc -l`
+passed=$(grep -c PASS: "${LOG}")
+failed=$(grep -c FAIL: "${LOG}")
 all=$((passed + failed))
 
 (   echo "=== Test Summary ==="
     echo "TOTAL: ${all}"
     echo "PASSED: ${passed}"
     echo "FAILED: ${failed}"
-) | tee -a ${LOG}
+) | tee -a "${LOG}"