Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [bug] shift: shell exits with status 0 on bad math expression
- X-seq: zsh-workers 43077
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: [bug] shift: shell exits with status 0 on bad math expression
- Date: Wed, 20 Jun 2018 10:12:54 +0100
- Cms-type: 201P
- Dkim-filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180620091311euoutp01942166b050cf7136dfc58f5a84246052~502fVfN3L1930019300euoutp01s
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1529485991; bh=BNAD8OZtQeAPFLDWn0ssH0RtaTDPgRJ0yjNl1zJ3LKM=; h=Date:From:To:Subject:In-Reply-To:References:From; b=pTYCjB2yiLGIRYoQT/y+96hlVfahIGGvcDu9VmmHWiyBJZrVrsmzDTPbXddTcUdJO aWW8TbdhBYEnQ3ENsxJQSVmsGM6lCfdjAzvFGKcO2knjWc7eponsrSxQ1mp1Pqj8w+ n+ylmcWfj9irge9IXluZ9tggXkiR7ZhO/ow+el9U=
- In-reply-to: <eceefa15-738b-2800-9865-4b3af2b6fb80@inlv.org>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Organization: SCSC
- References: <CGME20180620090022epcas1p4700aca92f8b52c669c5ac10165a6ce80@epcas1p4.samsung.com> <eceefa15-738b-2800-9865-4b3af2b6fb80@inlv.org>
On Wed, 20 Jun 2018 09:45:36 +0100
Martijn Dekker <martijn@xxxxxxxx> wrote:
> When an argument is given to 'shift' that constitutes a bad math
> expression, the (sub)shell prints an error and exits, but the exit
> status is zero (= success) under most conditions.
diff --git a/Src/builtin.c b/Src/builtin.c
index 1cba97d..93fa911 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -5318,8 +5318,13 @@ bin_shift(char *name, char **argv, Options ops, UNUSED(int func))
/* optional argument can be either numeric or an array */
queue_signals();
- if (*argv && !getaparam(*argv))
+ if (*argv && !getaparam(*argv)) {
num = mathevali(*argv++);
+ if (errflag) {
+ unqueue_signals();
+ return 1;
+ }
+ }
if (num < 0) {
unqueue_signals();
Messages sorted by:
Reverse Date,
Date,
Thread,
Author