Hello,

While learning m4/autoconf I seemed to forget about the importance of
quoting variables (see a similar issue Paul fixed with my byteswap.m4
changes)...

In a testdir on an AIX machine (cfarm111) I see this warning:

    ./configure[7173]: test: argument expected
    ./configure[7181]: test: argument expected

This is because the variables are not defined on this system and expand
to nothing. I've attached this patch fixing it. Lesson learned.

Collin

>From 2fc3ada5f86f05a0f10d2fe737de996011462e48 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Thu, 30 May 2024 04:46:29 -0700
Subject: [PATCH] endian: Quote variables that may be undefined (regr.
 2024-05-18).

* m4/endian_h.m4 (gl_ENDIAN_H): Quote variables that are undefined on
some systems or may be defined by the user.
---
 ChangeLog      |  6 ++++++
 m4/endian_h.m4 | 12 ++++++------
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 18a508ec94..2792ccbb79 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-05-30  Collin Funk  <collin.fu...@gmail.com>
+
+	endian: Quote variables that may be undefined (regr. 2024-05-18).
+	* m4/endian_h.m4 (gl_ENDIAN_H): Quote variables that are undefined on
+	some systems or may be defined by the user.
+
 2024-05-30  Bruno Haible  <br...@clisp.org>
 
 	call_once: Work around Cygwin 3.5.3 bug.
diff --git a/m4/endian_h.m4 b/m4/endian_h.m4
index 29dab603e3..a3b43b25b7 100644
--- a/m4/endian_h.m4
+++ b/m4/endian_h.m4
@@ -1,5 +1,5 @@
 # endian_h.m4
-# serial 2
+# serial 3
 dnl Copyright 2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -13,7 +13,7 @@ AC_DEFUN_ONCE([gl_ENDIAN_H]
 
   AC_CHECK_HEADERS_ONCE([endian.h])
   gl_CHECK_NEXT_HEADERS([endian.h])
-  if test $ac_cv_header_endian_h = yes; then
+  if test "$ac_cv_header_endian_h" = yes; then
     HAVE_ENDIAN_H=1
     dnl Check if endian.h defines uint16_t, uint32_t, and uint64_t.
     AC_CACHE_CHECK([if endian.h defines stdint types],
@@ -80,16 +80,16 @@ AC_DEFUN_ONCE([gl_ENDIAN_H]
   fi
 
   dnl Check if endian.h should be generated.
-  if test $gl_cv_header_endian_h_stdint_types = yes \
-     && test $gl_cv_header_working_endian_h = yes; then
+  if test "$gl_cv_header_endian_h_stdint_types" = yes \
+     && test "$gl_cv_header_working_endian_h" = yes; then
     GL_GENERATE_ENDIAN_H=false
   else
     GL_GENERATE_ENDIAN_H=true
   fi
 
   dnl Check if endian.h works but is missing types from stdint.h.
-  if test $GL_GENERATE_ENDIAN_H; then
-    if test $gl_cv_header_working_endian_h = yes; then
+  if test "$GL_GENERATE_ENDIAN_H"; then
+    if test "$gl_cv_header_working_endian_h" = yes; then
       ENDIAN_H_JUST_MISSING_STDINT=1
     else
       ENDIAN_H_JUST_MISSING_STDINT=0
-- 
2.45.1

Reply via email to