From: Christian Goeschel Ndjomouo Date: Fri, 10 Apr 2026 19:02:34 +0000 (-0400) Subject: tests: use bash parameter substitution instead of echo & sed X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=98c75a7efb0db4c019e840378f38bd836b4cd4dc;p=thirdparty%2Futil-linux.git tests: use bash parameter substitution instead of echo & sed This helps simplify the code and avoids unnecessary resource allocations due to the process and pipe creations caused by invocations of sed and echo. Signed-off-by: Christian Goeschel Ndjomouo --- diff --git a/tests/run.sh b/tests/run.sh index 52a463599..7e2dec7d1 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -232,7 +232,7 @@ echo printf "%13s: %-30s " "kernel" "$(uname -s) $(uname -r)" echo echo -echo " options: $(echo $OPTS | sed 's/ / \\\n /g')" +echo " options: ${OPTS// / $'\n' }" echo if [ "$paraller_jobs" -ne 1 ]; then diff --git a/tests/ts/cal/bigyear b/tests/ts/cal/bigyear index f590e4dfb..8671c2b15 100755 --- a/tests/ts/cal/bigyear +++ b/tests/ts/cal/bigyear @@ -31,7 +31,7 @@ CAL_TEST_TIME=1516562739 # 21st January 2018 export CAL_TEST_TIME function call_cal { - local testname=$(echo "$2" | sed 's/-//g') + local testname="${2//-/}" if [ "$3" == "$MYYEAR" ]; then testname="${testname}-year" diff --git a/tests/ts/cal/jan1753 b/tests/ts/cal/jan1753 index 3d2e97b1c..c0e7bc882 100755 --- a/tests/ts/cal/jan1753 +++ b/tests/ts/cal/jan1753 @@ -26,7 +26,7 @@ USETERM=$( ts_has_option "useterm" "$*" ) MYMONTH="1 1753" function call_cal { - local testname=$(echo "$2" | sed 's/-//g') + local testname="${2//-/}" ts_init_subtest "$testname" ts_log "$1" diff --git a/tests/ts/cal/sep1752 b/tests/ts/cal/sep1752 index 6544e97d0..bcbd307ef 100755 --- a/tests/ts/cal/sep1752 +++ b/tests/ts/cal/sep1752 @@ -39,8 +39,7 @@ function call_cal_simple { } function call_cal { - local testname=$(echo "$2" | sed 's/-//g') - + local testname="${2//-/}" if [ "$3" == "$MYYEAR" ]; then testname="${testname}-year" else diff --git a/tests/ts/cal/weekarg b/tests/ts/cal/weekarg index 3d7ff4abb..9052f100f 100755 --- a/tests/ts/cal/weekarg +++ b/tests/ts/cal/weekarg @@ -40,8 +40,7 @@ function call_cal_simple { } function call_cal { - local testname=$(echo "${2}" | sed 's/-//g') - testname="${testname}-$(echo "${3}" | sed 's/=//g;s/-//g')" + local testname="${2//-/}-${3//[-=]/}" ts_init_subtest "$testname" call_cal_simple "$@" @@ -49,8 +48,7 @@ function call_cal { } function call_cal_color { - local testname=$(echo "${2}" | sed 's/-//g') - testname="${testname}-$(echo "${3}" | sed 's/=//g;s/-//g')-color" + local testname="${2//-/}-${3//[-=]/}-color" ts_init_subtest "$testname" call_cal_simple "$@" --color=always diff --git a/tests/ts/cal/weeknum b/tests/ts/cal/weeknum index 9471ec25e..8f78c47ac 100755 --- a/tests/ts/cal/weeknum +++ b/tests/ts/cal/weeknum @@ -30,7 +30,7 @@ USETERM=$( ts_has_option "useterm" "$*" ) [ "$USETERM" == "yes" ] && TS_VERBOSE="yes" function call_cal { - local testname=$(echo "$2" | sed 's/-//g') + local testname="${2//-/}" ts_init_subtest "$testname" ts_log "$1" diff --git a/tests/ts/cal/year b/tests/ts/cal/year index 9035bb91f..9887f76c5 100755 --- a/tests/ts/cal/year +++ b/tests/ts/cal/year @@ -29,7 +29,7 @@ USETERM=$( ts_has_option "useterm" "$*" ) MYTIME="29 11 2006" function call_cal { - local testname=$(echo "$2" | sed 's/-//g') + local testname="${2//-/}" ts_init_subtest "$testname" ts_log "$1"