From 1869eeb393e2499e9949cc3458cdd74685342540 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 13 Dec 2012 10:36:59 +0000 Subject: 30876: fix obscure failures to propagate non-zero status from optimised simple commands within lists --- ChangeLog | 8 +++++++- Completion/Unix/Command/_perforce | 2 +- Src/exec.c | 6 +++--- Test/A06assign.ztst | 4 ++-- Test/C03traps.ztst | 11 +++++++++++ 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index f80e1a5c7..da6c87e89 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-12-13 Peter Stephenson + + * 30876: Src/exec.c, Test/A06assign.ztst, Test/C03traps.ztst: + obscure failures to process non-zero return values could result + from optimising a list to a simple command. + 2012-12-08 Bart Schaefer * users/17445: Src/math.c, Test/C01arith.ztst: fix handling of @@ -368,5 +374,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5766 $ +* $Revision: 1.5767 $ ***************************************************** diff --git a/Completion/Unix/Command/_perforce b/Completion/Unix/Command/_perforce index 78f6cd71e..d2943472c 100644 --- a/Completion/Unix/Command/_perforce +++ b/Completion/Unix/Command/_perforce @@ -2019,7 +2019,7 @@ _perforce_cmd_fix() { '-s[set job status]:status:_perforce_statuses' \ '1::-c required:(-c)' \ '2::change:_perforce_changes' \ - "3::job:_perforce_jobs$job" + "*::job:_perforce_jobs$job" } diff --git a/Src/exec.c b/Src/exec.c index 74b14d54d..1ecbc3967 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -1207,6 +1207,9 @@ execlist(Estate state, int dont_change_job, int exiting) } else donedebug = intrap ? 1 : 0; + /* Reset donetrap: this ensures that a trap is only * + * called once for each sublist that fails. */ + donetrap = 0; if (ltype & Z_SIMPLE) { next = state->pc + WC_LIST_SKIP(code); if (donedebug != 2) @@ -1214,9 +1217,6 @@ execlist(Estate state, int dont_change_job, int exiting) state->pc = next; goto sublist_done; } - /* Reset donetrap: this ensures that a trap is only * - * called once for each sublist that fails. */ - donetrap = 0; /* Loop through code followed by &&, ||, or end of sublist. */ code = *state->pc++; diff --git a/Test/A06assign.ztst b/Test/A06assign.ztst index 84500f605..9a0a4f0cc 100644 --- a/Test/A06assign.ztst +++ b/Test/A06assign.ztst @@ -184,8 +184,8 @@ typeset -A hash hash=(one 1) - h+=string - [[ $h[@] == string ]] + hash+=string + [[ $hash[@] == string ]] 0:add scalar to association # tests of var+=(array) diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst index 321f5e956..757f75ca4 100644 --- a/Test/C03traps.ztst +++ b/Test/C03traps.ztst @@ -388,6 +388,17 @@ >} >No, really exited + (set -e + printf "a\nb\n" | while read line + do + [[ $line = a* ]] || continue + ((ctr++)) + [[ $line = foo ]] + done + echo "ctr = $ctr" + ) +1:ERREXIT in loop with simple commands + %clean rm -f TRAPEXIT -- cgit 1.4.1