]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: use bash parameter substitution instead of echo & sed
authorChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Fri, 10 Apr 2026 19:02:34 +0000 (15:02 -0400)
committerChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Mon, 4 May 2026 11:31:11 +0000 (07:31 -0400)
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 <cgoesc2@wgu.edu>
tests/run.sh
tests/ts/cal/bigyear
tests/ts/cal/jan1753
tests/ts/cal/sep1752
tests/ts/cal/weekarg
tests/ts/cal/weeknum
tests/ts/cal/year

index 52a4635991b55404c7bb7fd11b714fbf10b3f479..7e2dec7d186a689f0fd9a60ff566dd2f18621a53 100755 (executable)
@@ -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
index f590e4dfb4df4c104032e93af2ab93b613b4d79d..8671c2b15b66a5e4c6d0712847f63b8489cddd17 100755 (executable)
@@ -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"
index 3d2e97b1c8d72e6804f518962e1fd74f664e9743..c0e7bc882fe1e0f3b38dfbe0b053d7ea94bf703a 100755 (executable)
@@ -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"
index 6544e97d0368db634ce9f90315e2caa1d18be4ab..bcbd307ef6ac0c1652587b37dd92e75014e85500 100755 (executable)
@@ -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
index 3d7ff4abb2e85a05aab21527fc5c24f1d061884d..9052f100f2c961612792cc85217d620f151d5d73 100755 (executable)
@@ -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
index 9471ec25e3aec5531af6495d10edf2935123004c..8f78c47ac0289509ec578bd1d08b50fd28bf9107 100755 (executable)
@@ -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"
index 9035bb91f4cd8d9a4f66a0d825dbeca93d122dc4..9887f76c52999eedff2db088699528b5b1be51ac 100755 (executable)
@@ -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"