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

Message ID 20230518125647.2105203-3-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.

The gen_directive_tests script uses a bash shebang so == does work, but
there's no reason this script can't just use the more portable form
anyway.

	PR bootstrap/105831

gcc/ChangeLog:

	* config.gcc: Use = operator instead of ==.

gcc/testsuite/ChangeLog:

	* gcc.test-framework/gen_directive_tests: Use = operator instead
	of ==.
---
 gcc/config.gcc                                       |  2 +-
 gcc/testsuite/gcc.test-framework/gen_directive_tests | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)
  

Comments

Jakub Jelinek May 18, 2023, 12:59 p.m. UTC | #1
On Thu, May 18, 2023 at 01:56:46PM +0100, Jonathan Wakely via Gcc-patches wrote:
> --- a/gcc/testsuite/gcc.test-framework/gen_directive_tests
> +++ b/gcc/testsuite/gcc.test-framework/gen_directive_tests
> @@ -322,8 +322,8 @@ two() {
>      echo "${GOOD_PROG}" >> $FILE1
>      echo "${GOOD_PROG}" > $FILE2
>  
> -    if [ "${FAIL_VERSION}" == "yes" ]; then
> -	if [ "${EXP}" == "${EXP_PASS}" ]; then
> +    if  "yes" ]; then

This line looks suspicious...

> +	if [ "${EXP}" = "${EXP_PASS}" ]; then
>  	    NAME=${KIND1}-${KIND2}-${EXP_FAIL}
>  	else
>  	    NAME=${KIND1}-${KIND2}-${EXP_XFAIL}
> @@ -364,8 +364,8 @@ three() {
>      echo "${GOOD_PROG}" >> $FILE1
>      echo "${GOOD_PROG}" > $FILE2
>  
> -    if [ "${FAIL_VERSION}" == "${yes}" ]; then
> -	if [ "${EXP}" == "${EXP_PASS}" ]; then
> +    if [ "${FAIL_VERSION}" = "${yes}" ]; then
> +	if [ "${EXP}" = "${EXP_PASS}" ]; then
>  	    NAME=${KIND1}-${KIND2}-${KIND3}-${EXP_FAIL}
>  	else
>  	    NAME=${KIND1}-${KIND2}-${KIND3}-${EXP_XFAIL}
> -- 
> 2.40.1

	Jakub
  
Jonathan Wakely May 18, 2023, 1:05 p.m. UTC | #2
On Thu, 18 May 2023 at 13:59, Jakub Jelinek wrote:

> On Thu, May 18, 2023 at 01:56:46PM +0100, Jonathan Wakely via Gcc-patches
> wrote:
> > --- a/gcc/testsuite/gcc.test-framework/gen_directive_tests
> > +++ b/gcc/testsuite/gcc.test-framework/gen_directive_tests
> > @@ -322,8 +322,8 @@ two() {
> >      echo "${GOOD_PROG}" >> $FILE1
> >      echo "${GOOD_PROG}" > $FILE2
> >
> > -    if [ "${FAIL_VERSION}" == "yes" ]; then
> > -     if [ "${EXP}" == "${EXP_PASS}" ]; then
> > +    if  "yes" ]; then
>
> This line looks suspicious...
>

Yikes! I think instead of clicking on the first '=' character I must have
selected the whole of `"${FAIL_VERSION}" =` and then deleted it all.

v2 patch at https://gcc.gnu.org/pipermail/gcc-patches/2023-May/618919.html


> > +     if [ "${EXP}" = "${EXP_PASS}" ]; then
> >           NAME=${KIND1}-${KIND2}-${EXP_FAIL}
> >       else
> >           NAME=${KIND1}-${KIND2}-${EXP_XFAIL}
> > @@ -364,8 +364,8 @@ three() {
> >      echo "${GOOD_PROG}" >> $FILE1
> >      echo "${GOOD_PROG}" > $FILE2
> >
> > -    if [ "${FAIL_VERSION}" == "${yes}" ]; then
> > -     if [ "${EXP}" == "${EXP_PASS}" ]; then
> > +    if [ "${FAIL_VERSION}" = "${yes}" ]; then
> > +     if [ "${EXP}" = "${EXP_PASS}" ]; then
> >           NAME=${KIND1}-${KIND2}-${KIND3}-${EXP_FAIL}
> >       else
> >           NAME=${KIND1}-${KIND2}-${KIND3}-${EXP_XFAIL}
> > --
> > 2.40.1
>
>         Jakub
>
>
  

Patch

diff --git a/gcc/config.gcc b/gcc/config.gcc
index e08c67d7cde..d88071773c9 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -2441,7 +2441,7 @@  riscv*-*-elf* | riscv*-*-rtems*)
 	  tmake_file="${tmake_file} riscv/t-rtems"
 	  ;;
 	*)
-	  if test "x${with_multilib_generator}" == xdefault; then
+	  if test "x${with_multilib_generator}" = xdefault; then
 		  case "x${enable_multilib}" in
 		  xno) ;;
 		  xyes) tmake_file="${tmake_file} riscv/t-elf-multilib" ;;
diff --git a/gcc/testsuite/gcc.test-framework/gen_directive_tests b/gcc/testsuite/gcc.test-framework/gen_directive_tests
index 29f0a734877..87b3f3d1b40 100644
--- a/gcc/testsuite/gcc.test-framework/gen_directive_tests
+++ b/gcc/testsuite/gcc.test-framework/gen_directive_tests
@@ -283,8 +283,8 @@  one() {
     echo "${GOOD_PROG}" >> $FILE1
     echo "${GOOD_PROG}" > $FILE2
 
-    if [ "${FAIL_VERSION}" == "yes" ]; then
-	if [ "${EXP}" == "${EXP_PASS}" ]; then
+    if [ "${FAIL_VERSION}" = "yes" ]; then
+	if [ "${EXP}" = "${EXP_PASS}" ]; then
 	    NAME=${KIND}-${EXP_FAIL}
 	else
 	    NAME=${KIND}-${EXP_XFAIL}
@@ -322,8 +322,8 @@  two() {
     echo "${GOOD_PROG}" >> $FILE1
     echo "${GOOD_PROG}" > $FILE2
 
-    if [ "${FAIL_VERSION}" == "yes" ]; then
-	if [ "${EXP}" == "${EXP_PASS}" ]; then
+    if  "yes" ]; then
+	if [ "${EXP}" = "${EXP_PASS}" ]; then
 	    NAME=${KIND1}-${KIND2}-${EXP_FAIL}
 	else
 	    NAME=${KIND1}-${KIND2}-${EXP_XFAIL}
@@ -364,8 +364,8 @@  three() {
     echo "${GOOD_PROG}" >> $FILE1
     echo "${GOOD_PROG}" > $FILE2
 
-    if [ "${FAIL_VERSION}" == "${yes}" ]; then
-	if [ "${EXP}" == "${EXP_PASS}" ]; then
+    if [ "${FAIL_VERSION}" = "${yes}" ]; then
+	if [ "${EXP}" = "${EXP_PASS}" ]; then
 	    NAME=${KIND1}-${KIND2}-${KIND3}-${EXP_FAIL}
 	else
 	    NAME=${KIND1}-${KIND2}-${KIND3}-${EXP_XFAIL}