autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] _AS_REEXEC_WITH_SHELL: don’t use AS_EXIT.


From: Eric Blake
Subject: Re: [PATCH] _AS_REEXEC_WITH_SHELL: don’t use AS_EXIT.
Date: Fri, 13 Mar 2020 13:11:40 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0

On 3/13/20 12:52 PM, Zack Weinberg wrote:
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(-)

ACK


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


--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




reply via email to

[Prev in Thread] Current Thread [Next in Thread]