From 3ae1e494f1fd67545955efae67aab6a734dac519 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 10 Jun 2024 11:33:12 -0700 Subject: [PATCH] [Tests] fix syntax in helper --- test/common.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/common.sh b/test/common.sh index 3fccea135eb..adef60ffbfa 100644 --- a/test/common.sh +++ b/test/common.sh @@ -123,14 +123,16 @@ parse_json() { buffer="" local char local len - len=${#json} + len=$(echo -n "$json" | wc -c) + local i + i=0 local arr_index arr_index=0 local in_array in_array=0 - for ((i = 0; i < len; i++)); do - char="${json:i:1}" + while [ $i -lt $len ]; do + char=$(echo "$json" | cut -c$((i + 1))) if [ "$in_string" -eq 1 ]; then if [ "$escaped" -eq 1 ]; then @@ -158,6 +160,7 @@ parse_json() { else buffer="$buffer$char" fi + i=$((i + 1)) continue fi @@ -191,6 +194,7 @@ parse_json() { fi ;; esac + i=$((i + 1)) done printf "%b" "$output"