From 0b37b5149d2fc56221267936753362bddce2ce4a Mon Sep 17 00:00:00 2001 From: "Barton E. Schaefer" Date: Wed, 27 Jan 2016 22:10:03 -0800 Subject: 37804 (plus 37816): first word following "repeat" should be evaluated as math --- Src/loop.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Src/loop.c') diff --git a/Src/loop.c b/Src/loop.c index 4def9b652..19d7f733e 100644 --- a/Src/loop.c +++ b/Src/loop.c @@ -493,7 +493,9 @@ execrepeat(Estate state, UNUSED(int do_exec)) tmp = ecgetstr(state, EC_DUPTOK, &htok); if (htok) singsub(&tmp); - count = atoi(tmp); + count = mathevali(tmp); + if (errflag) + return 1; pushheap(); cmdpush(CS_REPEAT); loops++; -- cgit v1.2.3 From 016929e043abb8ba778293c29081ca8e227c6e58 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 21 Jun 2016 16:12:51 +0100 Subject: 38734: fix final case clauses terminating with ;& --- ChangeLog | 3 +++ Src/loop.c | 2 +- Test/A01grammar.ztst | 8 ++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) (limited to 'Src/loop.c') diff --git a/ChangeLog b/ChangeLog index a65ba2970..fd58e7aa6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2016-06-21 Peter Stephenson + * 38734: Src/loop.c, Test/A01grammar.ztst: fix final case + clauses terminating with ;&. + * 38692: Doc/Zsh/restricted.yo, Src/params.c: IFS can't be changed in restricted mode. diff --git a/Src/loop.c b/Src/loop.c index 19d7f733e..fa7602e37 100644 --- a/Src/loop.c +++ b/Src/loop.c @@ -660,7 +660,7 @@ execcase(Estate state, int do_exec) execlist(state, 1, ((WC_CASE_TYPE(code) == WC_CASE_OR) && do_exec)); while (!retflag && wc_code(code) == WC_CASE && - WC_CASE_TYPE(code) == WC_CASE_AND) { + WC_CASE_TYPE(code) == WC_CASE_AND && state->pc < end) { state->pc = next; code = *state->pc++; next = state->pc + WC_CASE_SKIP(code); diff --git a/Test/A01grammar.ztst b/Test/A01grammar.ztst index 7eedfa6e0..394480c19 100644 --- a/Test/A01grammar.ztst +++ b/Test/A01grammar.ztst @@ -283,6 +283,14 @@ >2 >3 + case whatever in + (*) print yeah, right ;& + esac + print but well +0:'case', redundant final ";&" +>yeah, right +>but well + ## Select now reads from stdin if the shell is not interactive. ## Its own output goes to stderr. (COLUMNS=80 LINES=3 -- cgit v1.2.3 From f0ecf54ea67c4133be02d55304f15e9f44485786 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Mon, 26 Sep 2016 17:59:29 +0100 Subject: 39448: reset REPLY in select on user action --- ChangeLog | 5 +++++ Src/loop.c | 2 ++ 2 files changed, 7 insertions(+) (limited to 'Src/loop.c') diff --git a/ChangeLog b/ChangeLog index f2404aeba..890779515 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2016-09-26 Peter Stephenson + + * Martijn Dekker: 39448: Src/loop.c: reset REPLY in select when + needed on user action. + 2016-09-25 Peter Stephenson * 39436: Src/exec.c, Src/signals.c: Don't execute builtin if diff --git a/Src/loop.c b/Src/loop.c index fa7602e37..3b9d02144 100644 --- a/Src/loop.c +++ b/Src/loop.c @@ -289,6 +289,8 @@ execselect(Estate state, UNUSED(int do_exec)) } } else str = (char *)getlinknode(bufstack); + if (!str && !errflag) + setsparam("REPLY", ztrdup("")); /* EOF (user pressed Ctrl+D) */ if (!str || errflag) { if (breaks) breaks--; -- cgit v1.2.3 From 8f2ce89a0c80f6a0ecdc7c1189d6a94f620882f4 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 10 Oct 2016 10:55:48 +0100 Subject: 39599: Don't reset status before "case" execution --- ChangeLog | 5 +++++ Src/loop.c | 1 - Test/A01grammar.ztst | 8 ++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) (limited to 'Src/loop.c') diff --git a/ChangeLog b/ChangeLog index a1699ac24..0f41c18fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2016-10-10 Peter Stephenson + + * 39599: Src/loop.c, Test/A01grammar.ztst: Don't reset status + before "case" execution. + 2016-10-07 Daniel Shahaf * 39522: Doc/Zsh/contrib.yo: add-zsh-hook/add-zle-hook-widget: diff --git a/Src/loop.c b/Src/loop.c index 3b9d02144..94b61b7ed 100644 --- a/Src/loop.c +++ b/Src/loop.c @@ -592,7 +592,6 @@ execcase(Estate state, int do_exec) word = ecgetstr(state, EC_DUP, NULL); singsub(&word); untokenize(word); - lastval = 0; cmdpush(CS_CASE); while (state->pc < end) { diff --git a/Test/A01grammar.ztst b/Test/A01grammar.ztst index 0b1085c3e..0e77f3ebc 100644 --- a/Test/A01grammar.ztst +++ b/Test/A01grammar.ztst @@ -757,6 +757,14 @@ >} >Stuff here + (exit 37) + case $? in + (37) echo $? + ;; + esac +0:case retains exit status for execution of cases +>37 + x=1 x=2 | echo $x echo $x -- cgit v1.2.3 From 31c6cfca9cc665feae46f4680687e902ad1bf9d7 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Thu, 13 Oct 2016 11:30:32 +0200 Subject: 39625: case needs to reset lastval if no pattern matched --- ChangeLog | 5 +++++ Src/loop.c | 8 ++++++-- Test/A01grammar.ztst | 17 +++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) (limited to 'Src/loop.c') diff --git a/ChangeLog b/ChangeLog index f7f97bc0f..16a937e50 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2016-10-13 Peter Stephenson + + * 39625: Martijn Dekker: Src/loop.c, Test/A01grammar.ztst: case + needs to reset lastval if no pattern matched. + 2016-10-13 Oliver Kiddle * 39622: Test/Y03arguments.ztst: add test cases for recent diff --git a/Src/loop.c b/Src/loop.c index 94b61b7ed..b791a898d 100644 --- a/Src/loop.c +++ b/Src/loop.c @@ -584,7 +584,7 @@ execcase(Estate state, int do_exec) Wordcode end, next; wordcode code = state->pc[-1]; char *word, *pat; - int npat, save, nalts, ialt, patok; + int npat, save, nalts, ialt, patok, anypatok; Patprog *spprog, pprog; end = state->pc + WC_CASE_SKIP(code); @@ -592,6 +592,7 @@ execcase(Estate state, int do_exec) word = ecgetstr(state, EC_DUP, NULL); singsub(&word); untokenize(word); + anypatok = 0; cmdpush(CS_CASE); while (state->pc < end) { @@ -648,7 +649,7 @@ execcase(Estate state, int do_exec) *spprog = pprog; } if (pprog && pattry(pprog, word)) - patok = 1; + patok = anypatok = 1; state->pc += 2; nalts--; } @@ -679,6 +680,9 @@ execcase(Estate state, int do_exec) state->pc = end; + if (!anypatok) + lastval = 0; + return lastval; } diff --git a/Test/A01grammar.ztst b/Test/A01grammar.ztst index 0e77f3ebc..e4b6870d7 100644 --- a/Test/A01grammar.ztst +++ b/Test/A01grammar.ztst @@ -763,6 +763,23 @@ ;; esac 0:case retains exit status for execution of cases +>37 + + false + case stuff in + (nomatch) foo + ;; + esac + echo $? +0:case sets exit status to zero if no patterns are matched +>0 + + case match in + (match) true; false; (exit 37) + ;; + esac + echo $? +0:case keeps exit status of last command executed in compound-list >37 x=1 -- cgit v1.2.3 From 2c56c7e5e809476fc6511a9e634d2a977593ef9e Mon Sep 17 00:00:00 2001 From: "Barton E. Schaefer" Date: Sat, 5 Nov 2016 13:54:16 -0700 Subject: 39839: fix "return" from "if" condition --- ChangeLog | 2 ++ Src/loop.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'Src/loop.c') diff --git a/ChangeLog b/ChangeLog index bcea79190..fef3a92c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2016-11-05 Barton E. Schaefer + * 39839: Src/loop.c: fix "return" from "if" condition + * 39838: Src/builtin.c: another missing unqueue_signals() 2016-11-04 Oliver Kiddle diff --git a/Src/loop.c b/Src/loop.c index b791a898d..f65c72bf4 100644 --- a/Src/loop.c +++ b/Src/loop.c @@ -570,7 +570,8 @@ execif(Estate state, int do_exec) cmdpop(); } else { noerrexit = olderrexit; - lastval = 0; + if (!retflag) + lastval = 0; } state->pc = end; -- cgit v1.2.3 From ff365909105cc360f4d1384bd7ad56cdd97fec31 Mon Sep 17 00:00:00 2001 From: "Barton E. Schaefer" Date: Sat, 5 Nov 2016 18:23:04 -0700 Subject: 39844: fix "while" condition as per 39839 (commit 2c56c7e5) --- ChangeLog | 2 ++ Src/loop.c | 7 +++---- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'Src/loop.c') diff --git a/ChangeLog b/ChangeLog index fef3a92c9..629d36a7b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2016-11-05 Barton E. Schaefer + * 39844: Src/loop.c: fix "while" condition as per 39839 + * 39839: Src/loop.c: fix "return" from "if" condition * 39838: Src/builtin.c: another missing unqueue_signals() diff --git a/Src/loop.c b/Src/loop.c index f65c72bf4..367c0df5c 100644 --- a/Src/loop.c +++ b/Src/loop.c @@ -439,13 +439,12 @@ execwhile(Estate state, UNUSED(int do_exec)) if (!((lastval == 0) ^ isuntil)) { if (breaks) breaks--; - lastval = oldval; + if (!retflag) + lastval = oldval; break; } - if (retflag) { - lastval = oldval; + if (retflag) break; - } /* In case the loop body is also a functional no-op, * make sure signal handlers recognize ^C as above. */ -- cgit v1.2.3