Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [BUG] exec + builtin and traps



On Tue, 12 Sep 2017 12:02:57 +0200
Vincent Lefevre <vincent@xxxxxxxxxx> wrote:
> For zsh 5.4.1, the zshbuiltins(1) man page says:
> 
>     exec [ -cl ] [ -a argv0 ] [ command [ arg ... ] ]
>            Replace the current shell with command rather than forking.
>            If command is a shell builtin command or a shell  function,
>            the shell executes it, then immediately exits.

It means immediately after the command has finished executing, not while
it's executing.

> #!/usr/bin/env zsh
> 
> trap 'echo foo' USR1
> 
> echo $$
> ( sleep 1; kill -USR1 $$ ) &
> exec eval sleep 2

So in your case it's still exectuing the eval sleep 2.

I don't actually understand your interpretation --- given eval is a
builtin and the eval is going to take 2 seconds because it dispatches to
a sleep, how could the shell exit before that?

pws

diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index 3afe990..d6aa078 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -669,7 +669,7 @@ an empty string or whitespace) the return status is zero.
 item(tt(exec) [ tt(-cl) ] [ tt(-a) var(argv0) ] [ var(command) [ var(arg) ... ] ])(
 Replace the current shell with var(command) rather than forking.
 If var(command) is a shell builtin command or a shell function,
-the shell executes it, then immediately exits.
+the shell executes it, and exits when the command is complete.
 
 With tt(-c) clear the environment; with tt(-l) prepend tt(-) to the
 tt(argv[0]) string of the command executed (to simulate a login shell);



Messages sorted by: Reverse Date, Date, Thread, Author