Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] 'repeat' loops: Let the repeat count use $?.
- X-seq: zsh-workers 47296
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] 'repeat' loops: Let the repeat count use $?.
- Date: Wed, 5 Aug 2020 10:10:22 +0000
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2020-08/20200805101022.21209-1-danielsh%40tarpaulin.shahaf.local2>
- Authentication-results: zsh.org; iprev=pass (out1-smtp.messagingengine.com) smtp.remote-ip=66.111.4.25; dkim=pass header.d=daniel.shahaf.name header.s=fm1 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm3 header.a=rsa-sha256
- Delivery-date: Wed, 05 Aug 2020 10:23:04 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=from:to:subject:date:message-id :mime-version:content-transfer-encoding; s=fm1; bh=plCYGuyiqZl8R x4G3bG4qu1FTpAIIelHnudMoOHCH0E=; b=GqyQ1MI9BowvHA9d1ojsM6j1Qq+Wh h6EPADicHNGgZqoDx+viAS5Jqq6pfigMz7iRtIxTFJ6RZPCnO6hUilsH71vYmbNS COJ31d/o2YQpdnBqWIrnQvBA6to+8YN8smBWp3OUehO9IQOYY1Iq8+V4HJLME+gl WsnHR5H/BZHang1x0NVaxK8kHHUl3/9h2CtaESLMMatoYFYUtMrIO3vT2jYg0yis 9aBRdSPu9wtOTLQW9LivxRrdA3x6gqWtvoLWPVYwkdDPMnTdEb6C+leapw1zhR5x 0qY39r3pjwlzMPvTU9DE2FtMltlusDO1CypGqfJ72oFNFFZaTox1MJgqw==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=plCYGuyiqZl8Rx4G3 bG4qu1FTpAIIelHnudMoOHCH0E=; b=PwQOT2+32CgBoffnOnry350tPpZiU0HC6 0hPl/TX+Ez1rJRQ2uNdJBKHfzxWoBlzBykEx9/H9LUoNr8mkgONzWIJoLCZL5dLU 7IqFuCPU2fXr8j8VINy/9GV6Z5NJlncH7NaLgrWm4vaH+mfDGO79U0IGX4lY9osU /sloOr+aZUhwo3YklpxViWAxDgBBzITqyA3RT0L1Ty8nI9QTO2i21Eb2ephBEzAJ XhdotYa3mbxAWZPi3SD3xZHcJDyoLWDa+1YDDR2RsTOD4NGDEm/7KVX9kiiMPOuR XfJaus7rfz5UXGehkdt9npCQ9oQqu0Y1MhGxHMuk82uOVugjj2kBg==
- Envelope-to: archives@xxxxxxxxxxxx
- List-archive: <http://www.zsh.org/sympa/arc/zsh-workers>
- List-help: <mailto:sympa@zsh.org?subject=help>
- List-id: <zsh-workers.zsh.org>
- List-owner: <mailto:zsh-workers-request@zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-subscribe: <mailto:sympa@zsh.org?subject=subscribe%20zsh-workers>
- List-unsubscribe: <mailto:sympa@zsh.org?subject=unsubscribe%20zsh-workers>
- Sender: Sympa Owner <sympa@xxxxxxx>
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
+
Messages sorted by:
Reverse Date,
Date,
Thread,
Author