tools: tests: use read -r to avoid mangling backslashes
authorKent Gibson <warthog618@gmail.com>
Mon, 3 Jun 2024 11:56:24 +0000 (19:56 +0800)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 3 Jun 2024 12:02:35 +0000 (14:02 +0200)
Fix shellcheck SC2162[1] - read without -r will mangle backslashes.

[1] https://www.shellcheck.net/wiki/SC2162

Signed-off-by: Kent Gibson <warthog618@gmail.com>
Link: https://lore.kernel.org/r/20240603115628.102616-5-warthog618@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
tools/gpio-tools-test.bash

index b06529626ae45733acdf42ba6630fcc1b1fa85b0..efe558b51e1e22f17ecdc8bed421e56d3309fd78 100755 (executable)
@@ -188,7 +188,7 @@ dut_run() {
        shift
        coproc timeout 10s "$SOURCE_DIR/$cmd" "$@" 2>&1
        DUT_PID=$COPROC_PID
-       read -t1 -n1 -u ${COPROC[0]} DUT_FIRST_CHAR
+       read -r -t1 -n1 -u "${COPROC[0]}" DUT_FIRST_CHAR
 }
 
 dut_run_redirect() {
@@ -211,7 +211,7 @@ dut_read_redirect() {
 dut_read() {
        local LINE
        lines=()
-       while read -t 0.2 -u ${COPROC[0]} LINE
+       while read -r -t 0.2 -u "${COPROC[0]}" LINE
        do
                if [ -n "$DUT_FIRST_CHAR" ]
                then
@@ -234,7 +234,7 @@ dut_flush() {
        unset DUT_FIRST_CHAR
        while read -t 0 -u "${COPROC[0]}" _JUNK
        do
-               read -t 0.1 -u "${COPROC[0]}" _JUNK || true
+               read -r -t 0.1 -u "${COPROC[0]}" _JUNK || true
        done
 }
 
@@ -242,7 +242,7 @@ dut_flush() {
 dut_regex_match() {
        PATTERN=$1
 
-       read -t 0.2 -u ${COPROC[0]} LINE || (echo Timeout && false)
+       read -r -t 0.2 -u "${COPROC[0]}" LINE || (echo Timeout && false)
        if [ -n "$DUT_FIRST_CHAR" ]
        then
                LINE=${DUT_FIRST_CHAR}${LINE}