zsh-workers
 help / color / mirror / Atom feed
* [PATCH] 'repeat' loops: Let the repeat count use $?.
@ 2020-08-05 10:10 Daniel Shahaf
  0 siblings, 0 replies; only message in thread
From: Daniel Shahaf @ 2020-08-05 10:10 UTC (permalink / raw)
  To: zsh-workers

It's an arithmetic expression.
---
 Src/loop.c             | 2 +-
 Test/A05execution.ztst | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/Src/loop.c b/Src/loop.c
index f13c8c4a9..9fb45d076 100644
--- a/Src/loop.c
+++ b/Src/loop.c
@@ -497,7 +497,6 @@ execrepeat(Estate state, UNUSED(int do_exec))
 
     end = state->pc + WC_REPEAT_SKIP(code);
 
-    lastval = 0;
     tmp = ecgetstr(state, EC_DUPTOK, &htok);
     if (htok) {
 	singsub(&tmp);
@@ -506,6 +505,7 @@ execrepeat(Estate state, UNUSED(int do_exec))
     count = mathevali(tmp);
     if (errflag)
 	return 1;
+    lastval = 0;
     pushheap();
     cmdpush(CS_REPEAT);
     loops++;
diff --git a/Test/A05execution.ztst b/Test/A05execution.ztst
index 20a594b68..e07bd9cd9 100644
--- a/Test/A05execution.ztst
+++ b/Test/A05execution.ztst
@@ -401,3 +401,10 @@ F:anonymous function, and a descriptor leak when backgrounding a pipeline
  (( exit 130 ) | { sleep 1; echo hello })
 0:exit code 130 isn't mistaken for a signal (unit test for workers/46060)
 >hello
+
+  (exit 3); repeat '?' echo y
+0:'repeat' loop can use lastval in the count
+>y
+>y
+>y
+


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-05 10:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-05 10:10 [PATCH] 'repeat' loops: Let the repeat count use $? Daniel Shahaf

zsh-workers

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/zsh-workers

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 zsh-workers zsh-workers/ http://inbox.vuxu.org/zsh-workers \
		zsh-workers@zsh.org
	public-inbox-index zsh-workers

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.workers


code repositories for the project(s) associated with this inbox:

	https://git.vuxu.org/mirror/zsh/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git