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

Re: [BUG] 'exec' runs shell functions and builtins



2017-07-26 13:53:38 +0100, Peter Stephenson:
> This clarifies the normal behaviour.
> 
> diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
> index 333db1c..cbaf67a 100644
> --- a/Doc/Zsh/builtins.yo
> +++ b/Doc/Zsh/builtins.yo
> @@ -675,6 +675,10 @@ executed.
>  See ifzman(the section `Precommand Modifiers' in zmanref(zshmisc))\
>  ifnzman(noderef(Precommand Modifiers)).
>  
> +If the option tt(POSIX_BUILTINS) is not set, var(command) may be
> +interpreted as a shell builtin command or shell function: this is run as
> +normal (as if tt(exec) were not present), then the shell exits.
> +
[...]

(you jumped the gun a bit there. The issue is  only being
discussed on the austin-group mailing list. The standard is
currently unclear on the matter, it might very well change to
allow the zsh/pdksh behaviour. Then again, though the zsh
behaviour makes more sense to me, in sh emulation, what matters
more is compatibility and it seems more of the widely used sh
implementations got with the ksh88 way).

It might be worth adding that after

exec a_builtin

or

exec a_function

the EXIT, DEBUG or ERR traps will not be executed, as the text
above would suggest they may.

Other traps and asynchronous job notifications are still handled
though (as opposed to when one execs an external command).

Not sure it's worth saying what would (not) happen in

! exec something

or

time exec something

-- 
Stephane



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