Fix AS_ERROR for FreeBSD sh.

* lib/m4sugar/m4sh.m4 (_AS_ERROR_PREPARE): Rewrite as_fn_error
to take additional first argument STATUS instead of transporting
$? across shell function entry, which does not work with FreeBSD
sh.  Shift all other arguments by one, adjust.
(AS_ERROR): Pass EXIT-STATUS, defaulting to $?, to as_fn_error.
Report by Václav Haisman.

Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
This commit is contained in:
Ralf Wildenhues 2010-03-02 20:19:32 +01:00
parent c5f58b373f
commit cffdc39470
2 changed files with 18 additions and 11 deletions

View File

@ -1,5 +1,13 @@
2010-03-02 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
Fix AS_ERROR for FreeBSD sh.
* lib/m4sugar/m4sh.m4 (_AS_ERROR_PREPARE): Rewrite as_fn_error
to take additional first argument STATUS instead of transporting
$? across shell function entry, which does not work with FreeBSD
sh. Shift all other arguments by one, adjust.
(AS_ERROR): Pass EXIT-STATUS, defaulting to $?, to as_fn_error.
Report by Václav Haisman.
Fix `autom4te cache creation' testsuite failure on FreeBSD.
* tests/tools.at (autom4te cache creation): Normalize exit
status of failed redirection to 1, may be 2 with FreeBSD sh.

View File

@ -816,22 +816,22 @@ m4_define([AS_WARN],
# otherwise, assume the entire script does not do logging.
m4_define([_AS_ERROR_PREPARE],
[AS_REQUIRE_SHELL_FN([as_fn_error],
[AS_FUNCTION_DESCRIBE([as_fn_error], [ERROR]m4_ifval(AS_MESSAGE_LOG_FD,
[AS_FUNCTION_DESCRIBE([as_fn_error], [STATUS ERROR]m4_ifval(AS_MESSAGE_LOG_FD,
[[ [[LINENO LOG_FD]]]]),
[Output "`basename @S|@0`: error: ERROR" to stderr.]
m4_ifval(AS_MESSAGE_LOG_FD,
[[If LINENO and LOG_FD are provided, also output the error to LOG_FD,
referencing LINENO.]])
[Then exit the script with status $?, using 1 if that was 0.])],
[ as_status=$?; test $as_status -eq 0 && as_status=1
[Then exit the script with STATUS, using 1 if that was 0.])],
[ as_status=$[1]; test $as_status -eq 0 && as_status=1
m4_ifval(AS_MESSAGE_LOG_FD,
[m4_pushdef([AS_MESSAGE_LOG_FD], [$[3]])dnl
if test "$[3]"; then
AS_LINENO_PUSH([$[2]])
_AS_ECHO_LOG([error: $[1]])
[m4_pushdef([AS_MESSAGE_LOG_FD], [$[4]])dnl
if test "$[4]"; then
AS_LINENO_PUSH([$[3]])
_AS_ECHO_LOG([error: $[2]])
fi
m4_define([AS_MESSAGE_LOG_FD])], [m4_pushdef([AS_MESSAGE_LOG_FD])])dnl
AS_MESSAGE([error: $[1]], [2])
AS_MESSAGE([error: $[2]], [2])
_m4_popdef([AS_MESSAGE_LOG_FD])dnl
AS_EXIT([$as_status])])])
@ -842,9 +842,8 @@ _m4_popdef([AS_MESSAGE_LOG_FD])dnl
m4_defun_init([AS_ERROR],
[m4_append_uniq([_AS_CLEANUP],
[m4_divert_text([M4SH-INIT-FN], [_AS_ERROR_PREPARE[]])])],
[m4_ifvaln([$2], [{ AS_SET_STATUS([$2])])]dnl
[as_fn_error "_AS_QUOTE([$1])"m4_ifval(AS_MESSAGE_LOG_FD,
[ "$LINENO" AS_MESSAGE_LOG_FD])[]m4_ifval([$2], [; }])])
[as_fn_error m4_default([$2], [$?]) "_AS_QUOTE([$1])"m4_ifval(AS_MESSAGE_LOG_FD,
[ "$LINENO" AS_MESSAGE_LOG_FD])])
# AS_LINENO_PUSH([LINENO])