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

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



AFAIK zsh has always had this behavior.  It also allows for example
"exec builtin echo" as well as "builtin exec echo" etc.  What would
POSIX say that
    exec command echo foo
should do?  It's relatively easy to stop "exec" from finding functions
and builtin commands, but I think fairly painful to get it to ignore
other "precommand modifier" tokens.  Even after PWS's 41464 the above
example runs /bin/echo whereas I think the POSIX expectation would be
to report "command: command not found".

> This behaviour also appears to be contrary to the documentation in
> zshbuiltins(1) ("Replace the current shell with an external command
> rather than forking").

The documentation under "precommand modifiers" (which is
cross-referenced from zshbuiltins) says:

     The following command together with any arguments is run in place
     of the current process, rather than as a sub-process.  The shell
     does not fork and is replaced.

I think this is a case of the zshbuiltins doc being ancient and
imprecise rather than intentionally indicative of anything, but:



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