git: sh: Allow EV_EXIT through function calls.

Peter Avalos pavalos at
Sun Aug 21 16:33:12 PDT 2011

commit 2b23d27fbc13178e19021a1914a077c3274954f2
Author: Peter Avalos <pavalos at>
Date:   Sat Jul 2 13:38:15 2011 -1000

    sh: Allow EV_EXIT through function calls.
    make {...} <redir more consistent.
    If EV_EXIT causes an exit, use the exception mechanism to unwind
    redirections and local variables. This way, if the final command is a
    redirected command, an EXIT trap now executes without the redirections.
    Because of these changes, EV_EXIT can now be inherited by the body of a
    function, so do so. This means that a function no longer prevents a fork
    before an exec being skipped, such as in
      f() { head -1 /etc/passwd; }; echo $(f)
    Wrapping a single builtin in a function may still cause an otherwise
    unnecessary fork with command substitution, however.
    An exit command or -e failure still invokes the EXIT trap with the
    original redirections and local variables in place.
    Note: this depends on SHELLPROC being gone. A SHELLPROC depended on
    keeping the redirections and local variables and only cleaning up the
    state to restore them.
    Obtained-from:   FreeBSD SVN rev 220978

Summary of changes:
 bin/sh/error.h                             |    3 ++-
 bin/sh/eval.c                              |   27 ++++++++++++++-------------
 bin/sh/main.c                              |    5 +++--
 tools/regression/bin/sh/execution/fork3.0  |    4 ++++
 tools/regression/bin/sh/execution/redir6.0 |   21 +++++++++++++++++++++
 tools/regression/bin/sh/execution/redir7.0 |   21 +++++++++++++++++++++
 6 files changed, 65 insertions(+), 16 deletions(-)
 create mode 100644 tools/regression/bin/sh/execution/fork3.0
 create mode 100644 tools/regression/bin/sh/execution/redir6.0
 create mode 100644 tools/regression/bin/sh/execution/redir7.0

DragonFly BSD source repository

More information about the Commits mailing list