diff mbox series

m4: use test instead of []

Message ID 20200522112457.6640-1-wl@xen.org (mailing list archive)
State New, archived
Headers show
Series m4: use test instead of [] | expand

Commit Message

Wei Liu May 22, 2020, 11:24 a.m. UTC
It is reported that [] was removed by autoconf, which caused the
following error:

  ./configure: line 4681: -z: command not found

Switch to test. That's what is used throughout our configure scripts.

Reported-by: Bertrand Marquis <Bertrand.Marquis@arm.com>
Fixes: 8a6b1665d987 ("configure: also add EXTRA_PREFIX to {CPP/LD}FLAGS")
Reviewed-by: Roger Pau Monne <roger.pau@citrix.com>
Signed-off-by: Wei Liu <wl@xen.org>
---
Run autogen.sh before committing.

Cc: Bertrand Marquis <Bertrand.Marquis@arm.com>
Cc: Roger Pau Monne <roger.pau@citrix.com>
---
 m4/set_cflags_ldflags.m4 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ian Jackson May 22, 2020, 1:06 p.m. UTC | #1
Wei Liu writes ("[PATCH] m4: use test instead of []"):
> It is reported that [] was removed by autoconf, which caused the
> following error:
> 
>   ./configure: line 4681: -z: command not found
> 
> Switch to test. That's what is used throughout our configure scripts.

The reason for [ ] being removed is that configure.ac et al are
processed by m4 with quote characters set to [ ].

>      APPEND_LDFLAGS="$APPEND_LDFLAGS -L$ldflag"
>  done
> -if [ ! -z $EXTRA_PREFIX ]; then
> +if test ! -z $EXTRA_PREFIX ; then
>      CPPFLAGS="$CPPFLAGS -I$EXTRA_PREFIX/include"

If $EXTRA_PREFIX contains nothing (or just whitespace) this expands to
  test ! -z
which only works by accident.  It is parsed ax
  if not (string_is_nonempty("-z"))

Variable expansions in test expressions should generally be in " ".

Ian.
diff mbox series

Patch

diff --git a/m4/set_cflags_ldflags.m4 b/m4/set_cflags_ldflags.m4
index 08f5c983cc63..cd34c139bc94 100644
--- a/m4/set_cflags_ldflags.m4
+++ b/m4/set_cflags_ldflags.m4
@@ -15,7 +15,7 @@  for ldflag in $APPEND_LIB
 do
     APPEND_LDFLAGS="$APPEND_LDFLAGS -L$ldflag"
 done
-if [ ! -z $EXTRA_PREFIX ]; then
+if test ! -z $EXTRA_PREFIX ; then
     CPPFLAGS="$CPPFLAGS -I$EXTRA_PREFIX/include"
     LDFLAGS="$LDFLAGS -L$EXTRA_PREFIX/lib"
 fi