Here's one way to fix it. Since there were so many occurrences, I chose to encapsulate the test (and not expose/document the new macro).
I admit that this not a big deal, but even when I interrupt a configure script, I prefer to see it die cleanly. Otherwise, I have to wonder if some clean-up trap code also fails to run. Comments, suggestions ? >From a1c0ac7453b663d6886c96970dbf3161f0046c0c Mon Sep 17 00:00:00 2001 From: Jim Meyering <[EMAIL PROTECTED]> Date: Sun, 15 Jun 2008 17:56:37 +0200 Subject: [PATCH] AC_VAR_YES: new function, to handle an unusual failure Prompted by this (interrupting a configure run): $ ./configure ... checking for alloca... (cached) yes checking for arpa/inet.h... (cached) yes ^C./configure: line 6354: test: =: unary operator expected ,make: *** [config.status] Error 1 [Exit 130 (INT)] * lib/m4sugar/m4sh.m4 (AS_VAR_YES): New function. * lib/autoconf/functions.m4 (AC_CHECK_FUNC): Use it in place of "test AS_VAR_GET([...]) = yes" * lib/autoconf/general.m4 (AC_CHECK_FILE, AC_CHECK_DECL): Likewise. * lib/autoconf/headers.m4 (_AC_CHECK_HEADER_MONGREL): Likewise. (_AC_CHECK_HEADER_NEW, _AC_CHECK_HEADER_OLD): Likewise. (_AC_CHECK_HEADER_DIRENT): Likewise. * lib/autoconf/libs.m4 (AC_CHECK_LIB): Likewise. * lib/autoconf/types.m4 (_AC_CHECK_TYPE_NEW, AC_CHECK_MEMBER): Likewise. --- lib/autoconf/functions.m4 | 2 +- lib/autoconf/general.m4 | 4 ++-- lib/autoconf/headers.m4 | 8 ++++---- lib/autoconf/libs.m4 | 2 +- lib/autoconf/types.m4 | 4 ++-- lib/m4sugar/m4sh.m4 | 7 +++++++ 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4 index 78c7678..a15cdba 100644 --- a/lib/autoconf/functions.m4 +++ b/lib/autoconf/functions.m4 @@ -70,7 +70,7 @@ AC_CACHE_CHECK([for $1], [ac_var], [AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([$1])], [AS_VAR_SET([ac_var], [yes])], [AS_VAR_SET([ac_var], [no])])]) -AS_IF([test AS_VAR_GET([ac_var]) = yes], [$2], [$3])dnl +AS_IF([AS_VAR_YES([ac_var])], [$2], [$3])dnl AS_VAR_POPDEF([ac_var])dnl ])# AC_CHECK_FUNC diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index 8af0dc4..03e18e2 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -2614,7 +2614,7 @@ if test -r "$1"; then else AS_VAR_SET([ac_File], [no]) fi]) -AS_IF([test AS_VAR_GET([ac_File]) = yes], [$2], [$3])[]dnl +AS_IF([AS_VAR_YES([ac_File])], [$2], [$3])[]dnl AS_VAR_POPDEF([ac_File])dnl ])# AC_CHECK_FILE @@ -2651,7 +2651,7 @@ AC_CACHE_CHECK([whether $1 is declared], [ac_Symbol], ])], [AS_VAR_SET([ac_Symbol], [yes])], [AS_VAR_SET([ac_Symbol], [no])])]) -AS_IF([test AS_VAR_GET([ac_Symbol]) = yes], [$2], [$3])[]dnl +AS_IF([AS_VAR_YES([ac_Symbol])], [$2], [$3])[]dnl AS_VAR_POPDEF([ac_Symbol])dnl ])# AC_CHECK_DECL diff --git a/lib/autoconf/headers.m4 b/lib/autoconf/headers.m4 index 476df37..f2f2f54 100644 --- a/lib/autoconf/headers.m4 +++ b/lib/autoconf/headers.m4 @@ -143,7 +143,7 @@ esac AC_CACHE_CHECK([for $1], [ac_Header], [AS_VAR_SET([ac_Header], [$ac_header_preproc])]) ])dnl ! set ac_HEADER -AS_IF([test AS_VAR_GET([ac_Header]) = yes], [$2], [$3])[]dnl +AS_IF([AS_VAR_YES([ac_Header])], [$2], [$3])[]dnl AS_VAR_POPDEF([ac_Header])dnl ])# _AC_CHECK_HEADER_MONGREL @@ -160,7 +160,7 @@ AC_CACHE_CHECK([for $1], [ac_Header], @%:@include <$1>])], [AS_VAR_SET([ac_Header], [yes])], [AS_VAR_SET([ac_Header], [no])])]) -AS_IF([test AS_VAR_GET([ac_Header]) = yes], [$2], [$3])[]dnl +AS_IF([AS_VAR_YES([ac_Header])], [$2], [$3])[]dnl AS_VAR_POPDEF([ac_Header])dnl ])# _AC_CHECK_HEADER_NEW @@ -175,7 +175,7 @@ AC_CACHE_CHECK([for $1], [ac_Header], [AC_PREPROC_IFELSE([AC_LANG_SOURCE([EMAIL PROTECTED]:@include <$1>])], [AS_VAR_SET([ac_Header], [yes])], [AS_VAR_SET([ac_Header], [no])])]) -AS_IF([test AS_VAR_GET([ac_Header]) = yes], [$2], [$3])[]dnl +AS_IF([AS_VAR_YES([ac_Header])], [$2], [$3])[]dnl AS_VAR_POPDEF([ac_Header])dnl ])# _AC_CHECK_HEADER_OLD @@ -403,7 +403,7 @@ AC_CACHE_CHECK([for $1 that defines DIR], [ac_Header], return 0;])], [AS_VAR_SET([ac_Header], [yes])], [AS_VAR_SET([ac_Header], [no])])]) -AS_IF([test AS_VAR_GET([ac_Header]) = yes], [$2], [$3])[]dnl +AS_IF([AS_VAR_YES([ac_Header])], [$2], [$3])[]dnl AS_VAR_POPDEF([ac_Header])dnl ])# _AC_CHECK_HEADER_DIRENT diff --git a/lib/autoconf/libs.m4 b/lib/autoconf/libs.m4 index 429918c..04f7202 100644 --- a/lib/autoconf/libs.m4 +++ b/lib/autoconf/libs.m4 @@ -130,7 +130,7 @@ AC_LINK_IFELSE([AC_LANG_CALL([], [$2])], [AS_VAR_SET([ac_Lib], [yes])], [AS_VAR_SET([ac_Lib], [no])]) LIBS=$ac_check_lib_save_LIBS]) -AS_IF([test AS_VAR_GET([ac_Lib]) = yes], +AS_IF([AS_VAR_YES([ac_Lib])], [m4_default([$3], [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_LIB$1)) LIBS="-l$1 $LIBS" ])], diff --git a/lib/autoconf/types.m4 b/lib/autoconf/types.m4 index 50a489c..20ffb2b 100644 --- a/lib/autoconf/types.m4 +++ b/lib/autoconf/types.m4 @@ -160,7 +160,7 @@ AC_COMPILE_IFELSE( return 0;])], [], [AS_VAR_SET([ac_Type], [yes])])])]) -AS_IF([test AS_VAR_GET([ac_Type]) = yes], [$2], [$3])[]dnl +AS_IF([AS_VAR_YES([ac_Type])], [$2], [$3])[]dnl AS_VAR_POPDEF([ac_Type])dnl ])# _AC_CHECK_TYPE_NEW @@ -834,7 +834,7 @@ if (sizeof ac_aggr.m4_bpatsubst([$1], [^[^.]*\.])) return 0;])], [AS_VAR_SET([ac_Member], [yes])], [AS_VAR_SET([ac_Member], [no])])])]) -AS_IF([test AS_VAR_GET([ac_Member]) = yes], [$2], [$3])dnl +AS_IF([AS_VAR_YES([ac_Member])], [$2], [$3])dnl AS_VAR_POPDEF([ac_Member])dnl ])# AC_CHECK_MEMBER diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4 index 3dd735e..afa747a 100644 --- a/lib/m4sugar/m4sh.m4 +++ b/lib/m4sugar/m4sh.m4 @@ -1544,6 +1544,13 @@ m4_define([AS_VAR_SET], [eval "$1=AS_ESCAPE([$2])"])]) +# AS_VAR_YES(VARIABLE) +# -------------------- +# test whether VARIABLE has value "yes". +m4_define([AS_VAR_YES], +[as_yes=AS_VAR_GET([$1]); test "x$as_yes" = xyes]) + + # AS_VAR_GET(VARIABLE) # -------------------- # Get the value of the shell VARIABLE. -- 1.6.0.2.ge91c3