If a command named 'test_eval_override' exists, use it instead of 'eval' to run the test code. This is needed to support zsh test cases: test-lib.sh must be sourced in sh emulation mode due to fundamental incompatibilities between the POSIX sh language and the zsh language. When a function is defined while zsh is emulating some shell, zsh notes the shell that is being emulated and records it along with the function definition. This enables zsh to temporarily re-enable the shell emulation mode whenever the function is called, allowing zsh scripts to mix and match code written for different shell languages. (This description of zsh shell emulation is not completely accurate, but it's close enough.) Because test_eval_ is defined while zsh is in sh emulation mode, the shell code passed as an argument to test_expect_success would normally be evaluated in sh emulation mode. However, with this change, it is now possible to evaluate the test code in zsh mode by adding the following line to a zsh-based test script: emulate -R zsh -c 'test_eval_override () { eval "$*"; }' With test_eval_override defined in zsh emulation mode, the call to test_eval_override from test_eval_ will temporarily cause zsh to switch from sh emulation mode to zsh emulation mode. Signed-off-by: Richard Hansen <rhansen@xxxxxxx> --- t/test-lib.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/t/test-lib.sh b/t/test-lib.sh index c081668..3779634 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -414,7 +414,12 @@ maybe_setup_valgrind () { test_eval_ () { # This is a separate function because some tests use # "return" to end a test_expect_success block early. - eval </dev/null >&3 2>&4 "$*" + if command -v test_eval_override >/dev/null 2>&1 + then + test_eval_override "$*" + else + eval "$*" + fi </dev/null >&3 2>&4 } test_run_ () { -- 2.0.0 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html