+2008-10-30 Eric Blake <ebb9@byu.net>
+
+ Work around Solaris /bin/sh case bug.
+ * lib/m4sugar/m4sh.m4 (_AS_CASE, _AS_CASE_DEFAULT): Always provide
+ a non-empty command list.
+ (AS_CASE): Always guarantee that a case will match.
+ * doc/autoconf.texi (Limitations of Builtins) <case>: Document the
+ Solaris bug, and mention AS_CASE.
+
2008-10-30 Paolo Bonzini <bonzini@gnu.org>
Require _AS_CR_PREPARE where appropriate.
@error{}Syntax error: ";" unexpected (expecting ")")
@end example
+Posix requires @command{case} to give an exit status of 0 if no cases
+match. However, @command{/bin/sh} in Solaris 10 does not obey this
+rule. Meanwhile, it is unclear whether a case that matches, but
+contains no statements, must also change the exit status to 0. The M4sh
+macro @code{AS_CASE} works around these inconsistencies.
+
+@example
+$ @kbd{bash -c 'case `false` in ?) ;; esac; echo $?'}
+0
+$ @kbd{/bin/sh -c 'case `false` in ?) ;; esac; echo $?'}
+255
+@end example
+
@item @command{cd}
@c ---------------
# | *) DEFAULT ;;
# | esac
# The shell comments are intentional, to work around people who don't
-# realize the impacts of using insufficient m4 quoting.
+# realize the impacts of using insufficient m4 quoting. This macro
+# always provides a default case, to work around a Solaris /bin/sh
+# bug regarding the exit status when no case matches.
m4_define([_AS_CASE],
[ [@%:@(]
- $1[)] $2 ;;])
+ $1[)] m4_default([$2], [:]) ;;])
m4_define([_AS_CASE_DEFAULT],
[ [@%:@(]
- *[)] $1 ;;])
+ *[)] m4_default([$1], [:]) ;;])
m4_defun([AS_CASE],
-[case $1 in[]m4_map_args_pair([_$0], [_$0_DEFAULT], m4_shift($@))
+[case $1 in[]m4_map_args_pair([_$0], [_$0_DEFAULT],
+ m4_shift($@m4_if(m4_eval([$# & 1]), [1], [,])))
esac])# AS_CASE