Martijn Dekker <mart...@inlv.org> 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 
different.

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

Jörg

-- 
 EMail:jo...@schily.net                    (home) Jörg Schilling D-13353 Berlin
    joerg.schill...@fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/
 URL: http://cdrecord.org/private/ http://sf.net/projects/schilytools/files/'

Reply via email to