git: sh: Allow EV_EXIT through function calls.

看板DFBSD_commit作者時間14年前 (2011/08/22 08:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
commit 2b23d27fbc13178e19021a1914a077c3274954f2 Author: Peter Avalos <pavalos@dragonflybsd.org> 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 http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/2b23d27fbc13178e19021a1914a077c3274954f2 -- DragonFly BSD source repository
文章代碼(AID): #1EKPnBG2 (DFBSD_commit)