Martijn Dekker <> wrote:

> 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.

ksh93 is the only genetic shell in your list...
With genetic, i mean a shell that was derived from the Bourne Shell sources.

You could check the Bourne Shell (any version since 1984 when functions have 
been added) and verify that the correct behavior is to execute a binary with 
that name (overwriting the current shell process). Older Bourne Shells only 
fail because they did not support functions, but not because "exec" did behave 

> Which behaviour is correct?

The behavior that is compatibile to Bourne Shell nd ksh93.

In general, if Bourne Shell and ksh93 agree, this is most likely the right 
behavior unless you discovered a real bug.


--                    (home) Jörg Schilling D-13353 Berlin (work) Blog:

Reply via email to