Please find attached suggested patches for your consideration and review.

Bug fix for

AS_IF([false],[echo OK],[[]])

yielding the syntactically incorrect shell code:

if false; then :
  echo OK
else

fi


I hope that sending patches to the list as attachments is OK and they will
come through to the list.

Thanks,
J.
>From f38a8134c63a6bf5fbd1d7a33f85387e0864b188 Mon Sep 17 00:00:00 2001
From: Jannick <thirdedit...@gmx.net>
Date: Thu, 26 Dec 2019 03:06:29 +0100
Subject: [PATCH 2/2] m4sh/AS_IF: bug fix of previous buggy test case

* lib/m4sugar/m4sh.m4: replace `else' by `else :' in `_AS_IF_ELSE'.
---
 lib/m4sugar/m4sh.m4 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index d7e41673..4d357107 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -637,7 +637,7 @@ then :
 ])
 m4_define([_AS_IF_ELSE],
 [m4_ifnblank([$1],
-[else
+[else :
   $1
 ])])
 
-- 
2.24.1.windows.2

>From 4e55d3bfe31c4f869b2fb110140b379fe803c5ec Mon Sep 17 00:00:00 2001
From: Jannick <thirdedit...@gmx.net>
Date: Thu, 26 Dec 2019 02:53:01 +0100
Subject: [PATCH 1/2] m4sh/AS_IF: add a buggy test for AS_IF with blank false
 branch

The test

make check TESTSUITEFLAGS='-e -k m4sh,m4_map_args_pair'

fails, since m4sh generates from

AS_IF([false], [echo OK], [[]])

the syntactically incorrect shell code

if false; then :
      echo OK
else

fi

* tests/m4sh.at: add test `AS_IF([false], [:], [[]])'
---
 tests/m4sh.at | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/m4sh.at b/tests/m4sh.at
index cbdfcb62..e7d3c1ee 100644
--- a/tests/m4sh.at
+++ b/tests/m4sh.at
@@ -1240,7 +1240,7 @@ AS_CASE([`touch file; false`]) && test -f file && echo 
fifteen
 dnl The next line is badly underquoted; don't intentionally copy this style.
 AS_CASE([foo], [foo], m4_do(AS_CASE([bar], [bar], [echo sixteen])))
 dnl Handle blank arguments.
-AS_IF([false], [:], [ ]) && AS_CASE([foo], [foo], []
+AS_IF([false], [:], [ ]) && AS_IF([false], [:], [[]]) && AS_CASE([foo], [foo], 
[]
 ) && echo seventeen
 m4_define([empty])AS_IF([:], [empty]
 ) && AS_CASE([foo], [foo], [empty]) && echo eighteen
-- 
2.24.1.windows.2

Reply via email to