summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2020-03-13 13:38:46 -0400
committerZack Weinberg <zackw@panix.com>2020-03-13 13:38:46 -0400
commitb2e4b6333785aa55814bfd8f8747a9ce948fa88e (patch)
tree8433c3a5213083a7667d209a9ec02dd0bd859c65
parent2d06297bd550a0015f3ccedda9f43d7c616cfaf8 (diff)
downloadautoconf-b2e4b6333785aa55814bfd8f8747a9ce948fa88e.tar.gz
_AS_REEXEC_WITH_SHELL: don’t use AS_EXIT.
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.
-rw-r--r--lib/m4sugar/m4sh.m45
1 files changed, 4 insertions, 1 deletions
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