Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Error status of "repeat" (was Re: [PATCH] typeset: set $? on incidental error)
- X-seq: zsh-workers 37804
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Error status of "repeat" (was Re: [PATCH] typeset: set $? on incidental error)
- Date: Tue, 26 Jan 2016 20:15:13 -0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version:content-type; bh=ceNjJDt+5fIWbo+8T/fylDpo/H9T2cm6oGnxboxodp4=; b=H2AYxFbxnxKW87RrZo9uwggeNpT6M7+Yn/xZ/242xbgPv1cvcXP2YBO9XZHT+cioUM pOcmJsH98dktJo7bIL3dtmmpNBXoZMMODDZjgfFAdKEBOEVfNdIpHm4llSlU+6qU84Ys Nn3cf9V/lBbQq1uN+cF/R2d5CUqNxC5n8Rt1GfSHw1cGZ09bYf4vOezS03BBdUtCebdL yqToWu0gfY+PrSuZXFarPnjEgwt3+gwNBXbPCAVXOgf5dLQb4a0queqO+7Ns72DKkuWb pweUWf6F/D09ZwiliwPrLbQTRUlye5QADouV+PoynpytOyDD3nS/90gEUmuCzsLCH+by SMvA==
- In-reply-to: <20160126225008.GA4731@tarsus.local2>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20160123235300.GC20278@tarsus.local2> <56A445E0.50706@gmx.com> <20160126225008.GA4731@tarsus.local2>
On Jan 26, 10:50pm, Daniel Shahaf wrote:
}
} What would you expect "repeat 0+++ (exit 42)" to set $? to?
In fact what it does set $? to, is 0.
} repeat WORD do LIST done
} WORD is expanded and treated as an arithmetic expression, which
} must evaluate to a number N. LIST is then executed N times.
Hmm, this doesn't actually appear to happen.
torch% x=1+3
torch% repeat x print -n Z
torch% repeat $x print Z
Z
torch%
So it's just peeling the first thing that looks like a number off the
WORD and repeating that many times, or zero times if WORD is not a number.
BUT! Even if we change the code --
diff --git a/Src/loop.c b/Src/loop.c
index 4def9b6..61dad09 100644
--- a/Src/loop.c
+++ b/Src/loop.c
@@ -493,7 +493,7 @@ execrepeat(Estate state, UNUSED(int do_exec))
tmp = ecgetstr(state, EC_DUPTOK, &htok);
if (htok)
singsub(&tmp);
- count = atoi(tmp);
+ count = mathevali(tmp);
pushheap();
cmdpush(CS_REPEAT);
loops++;
-- that doesn't change the exit status!
torch% repeat 0+++ (exit 42)
zsh: bad math expression: lvalue required
torch% print $?
0
Next question: Do I commit that patch?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author