If _AS_REEXEC_WITH_SHELL fails to exec the selected “better” shell interpreter, and that failure somehow doesn’t terminate the process, it calls AS_EXIT([255]). This expands to an invocation of as_fn_exit. However, the definition of as_fn_exit goes into the M4SH-INIT-FN diversion, whereas _AS_REEXEC_WITH_SHELL goes into the M4SH-SANITIZE diversion, so as_fn_exit won’t be defined at the point of this use. We can’t move the definition of as_fn_exit earlier, because we don’t know that the shell supports shell functions until after we get to the end of the M4SH-SANITIZE diversion.
This is only a theoretical bug because, as the comments say, “all the known shells bail out after a failed exec.” However, a shell that doesn’t bail out will instead give the user a flood of nonsensical error messages (starting with “as_fn_exit: not found” and then going on to choke on the rest of the script) so I think we should fix it anyway. There shouldn’t be any problem with using a plain ‘exit’ at this point; no traps are active yet, and we are exiting with an explicit error code. OK to commit? zw --- lib/m4sugar/m4sh.m4 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4 index 92999f58..4af31517 100644 --- a/lib/m4sugar/m4sh.m4 +++ b/lib/m4sugar/m4sh.m4 @@ -294,7 +294,10 @@ exec $1 $as_opts "$as_myself" ${1+"$[@]"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. AS_ECHO(["$[]0: could not re-execute with $1"]) >&2 -AS_EXIT([255])])# _AS_REEXEC_WITH_SHELL +dnl AS_EXIT cannot be used here because as_fn_exit is not yet defined; +dnl code inserted by AS_REQUIRE_SHELL_FN will appear _after_ this point. +dnl We shouldn't have to worry about any traps being active at this point. +exit 255])# _AS_REEXEC_WITH_SHELL # _AS_PREPARE -- 2.25.1