Martijn Dekker <mart...@inlv.org> wrote, on 16 Jul 2017:
>
> A test script:
> 
> #! /bin/sh
> true() {
>       echo "exec runs function"
> }
> exec true
> 
> On zsh, pdksh and mksh, 'exec' runs the shell function. On all other
> POSIX shells (at least bash, dash, yash, ksh93, FreeBSD sh), it runs the
> external 'true' utility.
> 
> Which behaviour is correct?

I just noticed something not touched on in the previous discussion.

The EXIT STATUS section for exec says:

    If <i>command</i> is specified, exec shall not return to the shell;
    rather, the exit status of the process shall be the exit status of
    the program implementing <i>command</i>, which overlaid the shell.

The use of "program" and "overlaid the shell" here means that the
standard clearly does not allow the execution of built-in utilities and
functions.

Of course, we could still choose to treat this as a defect in the
standard.

-- 
Geoff Clare <g.cl...@opengroup.org>
The Open Group, Apex Plaza, Forbury Road, Reading, RG1 1AX, England

Reply via email to