Avoid syntax error if IF-TRUE part of AM_COND_IF expands empty.
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Tue, 27 Jul 2010 19:20:04 +0000 (21:20 +0200)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Tue, 27 Jul 2010 19:31:33 +0000 (21:31 +0200)
* m4/cond-if.m4 (AM_COND_IF): Ensure IF-TRUE part is never empty
to avoid shell syntax error if the m4 expansion is empty.
* tests/cond40.test: Enhance test.

Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
ChangeLog
m4/cond-if.m4
tests/cond40.test

index e8ffcf8..2312301 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2010-07-27  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
+       Avoid syntax error if IF-TRUE part of AM_COND_IF expands empty.
+       * m4/cond-if.m4 (AM_COND_IF): Ensure IF-TRUE part is never empty
+       to avoid shell syntax error if the m4 expansion is empty.
+       * tests/cond40.test: Enhance test.
+
        Coverage: bogus option to AM_INIT_AUTOMAKE.
        * tests/init2.test: New test.
        * tests/Makefile.am: Update.
index 9f2611e..2500422 100644 (file)
@@ -1,12 +1,12 @@
 # AM_COND_IF                                            -*- Autoconf -*-
 
-# Copyright (C) 2008 Free Software Foundation, Inc.
+# Copyright (C) 2008, 2010 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 1
+# serial 2
 
 # _AM_COND_IF
 # _AM_COND_ELSE
@@ -27,8 +27,8 @@ AC_DEFUN([AM_COND_IF],
 [m4_ifndef([_AM_COND_VALUE_$1],
           [m4_fatal([$0: no such condition "$1"])])dnl
 _AM_COND_IF([$1])dnl
-if _AM_COND_VALUE_$1; then
-  m4_default([$2], [:])
+if _AM_COND_VALUE_$1; then :
+  m4_n([$2])[]dnl
 m4_ifval([$3],
 [_AM_COND_ELSE([$1])dnl
 else
index be94fe3..d30f0ab 100755 (executable)
@@ -1,5 +1,5 @@
-#!/bin/sh
-# Copyright (C) 2008  Free Software Foundation, Inc.
+#! /bin/sh
+# Copyright (C) 2008, 2010 Free Software Foundation, Inc.
 #
 # This file is part of GNU Automake.
 #
@@ -28,6 +28,10 @@ AC_DEFUN([FOO],
         [AC_CONFIG_FILES([$1])])
 
 AM_CONDITIONAL([COND], [test "$cond" = yes])
+# Next lines should not cause a shell syntax error.
+AM_COND_IF([COND])
+AM_COND_IF([COND],
+          [AC_SUBST([BAR])])
 AM_COND_IF([COND],
           [AC_CONFIG_FILES([file1])])