zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [bug] shift: shell exits with status 0 on bad math expression
Date: Wed, 20 Jun 2018 10:12:54 +0100	[thread overview]
Message-ID: <20180620091300eucas1p2211ee4b522ce901e37a5287431ffdb0c~502U8aqP-3109831098eucas1p2y@eucas1p2.samsung.com> (raw)
In-Reply-To: <eceefa15-738b-2800-9865-4b3af2b6fb80@inlv.org>

On Wed, 20 Jun 2018 09:45:36 +0100
Martijn Dekker <martijn@inlv.org> 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();


      reply	other threads:[~2018-06-20  9:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20180620090022epcas1p4700aca92f8b52c669c5ac10165a6ce80@epcas1p4.samsung.com>
2018-06-20  8:45 ` Martijn Dekker
2018-06-20  9:12   ` Peter Stephenson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='20180620091300eucas1p2211ee4b522ce901e37a5287431ffdb0c~502U8aqP-3109831098eucas1p2y@eucas1p2.samsung.com' \
    --to=p.stephenson@samsung.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).