[3/3] contrib: Fix nonportable shell syntax in "test" and "[" commands [PR105831]

Message ID 20230518125647.2105203-4-jwakely@redhat.com
State Accepted
Headers
Series Fix nonportable shell syntax in "test" and "[" commands |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Jonathan Wakely May 18, 2023, 12:56 p.m. UTC
  POSIX sh does not support the == for string comparisons, use = instead.

These contrib scripts all use a bash shebang so == does work, but
there's no reason they can't just use the more portable form anyway.

	PR bootstrap/105831

contrib/ChangeLog:

	* bench-stringop: Use = operator instead of ==.
	* repro_fail: Likewise.

contrib/reghunt/ChangeLog:

	* bin/reg-hunt: Use = operator instead of ==.
---
 contrib/bench-stringop       | 4 ++--
 contrib/reghunt/bin/reg-hunt | 2 +-
 contrib/repro_fail           | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)
  

Comments

Jakub Jelinek May 18, 2023, 1 p.m. UTC | #1
On Thu, May 18, 2023 at 01:56:47PM +0100, Jonathan Wakely via Gcc-patches wrote:
> POSIX sh does not support the == for string comparisons, use = instead.
> 
> These contrib scripts all use a bash shebang so == does work, but
> there's no reason they can't just use the more portable form anyway.
> 
> 	PR bootstrap/105831
> 
> contrib/ChangeLog:
> 
> 	* bench-stringop: Use = operator instead of ==.
> 	* repro_fail: Likewise.
> 
> contrib/reghunt/ChangeLog:
> 
> 	* bin/reg-hunt: Use = operator instead of ==.

LGTM.

	Jakub
  

Patch

diff --git a/contrib/bench-stringop b/contrib/bench-stringop
index daf1bce6e6f..f058e066b3a 100755
--- a/contrib/bench-stringop
+++ b/contrib/bench-stringop
@@ -87,7 +87,7 @@  test "$2" "$3" "-mstringop-strategy=rep_byte -malign-stringops" rep1
 test "$2" "$3" "-mstringop-strategy=rep_byte -mno-align-stringops" rep1noalign
 test "$2" "$3" "-mstringop-strategy=rep_4byte -malign-stringops" rep4
 test "$2" "$3" "-mstringop-strategy=rep_4byte -mno-align-stringops" rep4noalign
-if [ "$mode" == 64 ]
+if [ "$mode" = 64 ]
 then
 test "$2" "$3" "-mstringop-strategy=rep_8byte -malign-stringops" rep8
 test "$2" "$3" "-mstringop-strategy=rep_8byte -mno-align-stringops" rep8noalign
@@ -109,7 +109,7 @@  echo "    $best"
 
 test_all_sizes()
 {
-if [ "$mode" == 64 ]
+if [ "$mode" = 64 ]
 then
 echo "  block size  libcall rep1    noalg   rep4    noalg   rep8    noalg   loop    noalg   unrl    noalg   sse     noalg   byte    PGO     dynamic    BEST"
 else
diff --git a/contrib/reghunt/bin/reg-hunt b/contrib/reghunt/bin/reg-hunt
index 6427535dabe..aff4e9005b5 100755
--- a/contrib/reghunt/bin/reg-hunt
+++ b/contrib/reghunt/bin/reg-hunt
@@ -142,7 +142,7 @@  process_patch () {
     # build failures, quit now.
 
     if [ ${SKIP} -eq 0 ]; then
-      if [ "x${REG_NEWMID}" == "x" \
+      if [ "x${REG_NEWMID}" = "x" \
            -o ${TEST_ID} -eq ${LATER_THAN} \
            -o ${TEST_ID} -eq ${EARLIER_THAN} ]; then
         error "build failed for ${TEST_ID}"
diff --git a/contrib/repro_fail b/contrib/repro_fail
index 9ea79f2bccf..abb479d08aa 100755
--- a/contrib/repro_fail
+++ b/contrib/repro_fail
@@ -42,10 +42,10 @@  if [ $# -lt 2 ] ; then
     exit 1
 fi
 
-if [ "$1" == "--debug" ] ; then
+if [ "$1" = "--debug" ] ; then
     debug_args="-wrapper gdb,--args"
     shift
-elif [ "$1" == "--debug-tui" ] ; then
+elif [ "$1" = "--debug-tui" ] ; then
     debug_args="-wrapper gdb,--tui,--args"
     shift
 else