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

Message ID 20230518125647.2105203-2-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
  From: Michael Bäuerle <micha@NetBSD.org>

POSIX sh does not support the == for string comparisons, use = instead.

gcc/ChangeLog:

	PR bootstrap/105831
	* config/nvptx/gen-opt.sh: Use = operator instead of ==.
	* configure.ac: Likewise.
	* configure: Regenerate.
---
 gcc/config/nvptx/gen-opt.sh | 2 +-
 gcc/configure               | 2 +-
 gcc/configure.ac            | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
  

Comments

Jakub Jelinek May 18, 2023, 1 p.m. UTC | #1
On Thu, May 18, 2023 at 01:56:45PM +0100, Jonathan Wakely via Gcc-patches wrote:
> From: Michael B??uerle <micha@NetBSD.org>
> 
> POSIX sh does not support the == for string comparisons, use = instead.
> 
> gcc/ChangeLog:
> 
> 	PR bootstrap/105831
> 	* config/nvptx/gen-opt.sh: Use = operator instead of ==.
> 	* configure.ac: Likewise.
> 	* configure: Regenerate.

LGTM.

	Jakub
  
Bernhard Reutner-Fischer May 18, 2023, 2:47 p.m. UTC | #2
On 18 May 2023 14:56:45 CEST, Jonathan Wakely via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>From: Michael B��uerle <micha@NetBSD.org>
>
>POSIX sh does not support the == for string comparisons, use = instead.
>
>gcc/ChangeLog:
>
>	PR bootstrap/105831

> 
>diff --git a/gcc/configure.ac b/gcc/configure.ac
>index 075424669c9..cc8dd9e20bf 100644
>--- a/gcc/configure.ac
>+++ b/gcc/configure.ac
>@@ -473,7 +473,7 @@ AC_CHECK_SIZEOF(dev_t)
> if test "$enable_largefile" != no; then
>   case "$host, $build" in
>     *-*-aix*,*|*,*-*-aix*)
>-      if test "$ac_cv_sizeof_ino_t" == "4" -a "$ac_cv_sizeof_dev_t" == 4; then
>+      if test "$ac_cv_sizeof_ino_t" = "4" -a "$ac_cv_sizeof_dev_t" = 4; then

test(1) -a and -o are marked obsolescent in SUS and should be spelled out as && or ||, respectively: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html

thanks,
  
Jonathan Wakely May 18, 2023, 3:13 p.m. UTC | #3
On Thu, 18 May 2023 at 15:47, Bernhard Reutner-Fischer <
rep.dot.nop@gmail.com> wrote:

> On 18 May 2023 14:56:45 CEST, Jonathan Wakely via Gcc-patches <
> gcc-patches@gcc.gnu.org> wrote:
> >From: Michael B��uerle <micha@NetBSD.org>
> >
> >POSIX sh does not support the == for string comparisons, use = instead.
> >
> >gcc/ChangeLog:
> >
> >       PR bootstrap/105831
>
> >
> >diff --git a/gcc/configure.ac b/gcc/configure.ac
> >index 075424669c9..cc8dd9e20bf 100644
> >--- a/gcc/configure.ac
> >+++ b/gcc/configure.ac
> >@@ -473,7 +473,7 @@ AC_CHECK_SIZEOF(dev_t)
> > if test "$enable_largefile" != no; then
> >   case "$host, $build" in
> >     *-*-aix*,*|*,*-*-aix*)
> >-      if test "$ac_cv_sizeof_ino_t" == "4" -a "$ac_cv_sizeof_dev_t" ==
> 4; then
> >+      if test "$ac_cv_sizeof_ino_t" = "4" -a "$ac_cv_sizeof_dev_t" = 4;
> then
>
> test(1) -a and -o are marked obsolescent in SUS and should be spelled out
> as && or ||, respectively:
> https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html
>


To be precise, it would be:

if test "$ac_cv_sizeof_ino_t" = "4" && test "$ac_cv_sizeof_dev_t" = 4; then

i.e. not just replacing -a with &&

The == causes real errors with some sh implementations, so fixing that
fixes bootstrap errors, and was the source of a bug report (and patch
submission). Using -a isn't causing errors for anybody AFAIK, so is less
important.

I'll take a look at the libstdc++ configury though, as I've been meaning to
modernise some of it and am already making changes there.
  

Patch

diff --git a/gcc/config/nvptx/gen-opt.sh b/gcc/config/nvptx/gen-opt.sh
index dc10722b96f..cab73f5e663 100644
--- a/gcc/config/nvptx/gen-opt.sh
+++ b/gcc/config/nvptx/gen-opt.sh
@@ -56,7 +56,7 @@  EnumValue
 Enum(ptx_isa) String(sm_$sm) Value(PTX_ISA_SM$sm)
 EOF
 
-    if [ "$sm" == "$last" ]; then
+    if [ "$sm" = "$last" ]; then
 	# Don't end with trailing empty line.
 	continue
     fi
diff --git a/gcc/configure b/gcc/configure
index 191f68581b3..5f67808b774 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -6409,7 +6409,7 @@  _ACEOF
 if test "$enable_largefile" != no; then
   case "$host, $build" in
     *-*-aix*,*|*,*-*-aix*)
-      if test "$ac_cv_sizeof_ino_t" == "4" -a "$ac_cv_sizeof_dev_t" == 4; then
+      if test "$ac_cv_sizeof_ino_t" = "4" -a "$ac_cv_sizeof_dev_t" = 4; then
 
 $as_echo "#define HOST_STAT_FOR_64BIT_INODES stat64x" >>confdefs.h
 
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 075424669c9..cc8dd9e20bf 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -473,7 +473,7 @@  AC_CHECK_SIZEOF(dev_t)
 if test "$enable_largefile" != no; then
   case "$host, $build" in
     *-*-aix*,*|*,*-*-aix*)
-      if test "$ac_cv_sizeof_ino_t" == "4" -a "$ac_cv_sizeof_dev_t" == 4; then
+      if test "$ac_cv_sizeof_ino_t" = "4" -a "$ac_cv_sizeof_dev_t" = 4; then
 	AC_DEFINE(HOST_STAT_FOR_64BIT_INODES, stat64x,
 	  [Define which stat syscall is able to handle 64bit indodes.])
       fi;;