zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh workers <zsh-workers@zsh.org>
Subject: Re: TRY_BLOCK_ERROR and exit status
Date: Tue, 25 Nov 2014 00:01:23 -0800	[thread overview]
Message-ID: <141125000123.ZM17533@torch.brasslantern.com> (raw)
In-Reply-To: <20141124101152.39741cc8@pwslap01u.europe.root.pri>

On Nov 24, 10:11am, Peter Stephenson wrote:
}
} > other hand I think always+TRY_BLOCK_ERROR is the only way lastval can
} > still be examined after errflag has been set, so maybe it would suffice
} > to handle this there?
} 
} Yes, probably.
} 
} > What should the value of lastval ($?) be in this circumstance?
} 
} The easiest way out is probably to leave it if it's non-zero, else set
} it to 1.
} 
} Given that "always" isn't all that widely used, changing it to return
} the last status of the always block might also work.  However, it
} doesn't look necessary to go that far.

Do you mean return the last status of the always block only in the case
where errflag is nonzero at the end of the try block?  If that's not
what you mean, wouldn't that break the current normal use case where
always is for cleaning up whether or not there was an error?

I agree it isn't necessary to go that far.  This?


diff --git a/Src/loop.c b/Src/loop.c
index 2f639fd..82d2fe3 100644
--- a/Src/loop.c
+++ b/Src/loop.c
@@ -659,8 +659,9 @@ exectry(Estate state, int do_exec)
 
     try_tryflag = save_try_tryflag;
 
-    /* Don't record errflag here, may be reset. */
-    endval = lastval;
+    /* Don't record errflag here, may be reset.  However, */
+    /* endval should show failure when there is an error. */
+    endval = lastval ? lastval : errflag;
 
     freeheap();
 


  reply	other threads:[~2014-11-25  8:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-22 17:13 BUG: failure in "vcs_info prompt" aborts precmd function Daniel Hahler
2014-11-22 17:20 ` [PATCH] vcs_info: test -f .git/rebase-merge/done before reading it Daniel Hahler
2014-11-22 17:51 ` BUG: failure in "vcs_info prompt" aborts precmd function Mikael Magnusson
2014-11-22 18:01   ` Daniel Hahler
2014-11-22 22:20     ` Mikael Magnusson
2014-11-22 22:44       ` Bart Schaefer
2014-11-23 19:02         ` Peter Stephenson
2014-11-23 19:38           ` Bart Schaefer
2014-11-23 20:04             ` Peter Stephenson
2014-11-23 15:58       ` Daniel Hahler
2014-11-23 18:08         ` Mikael Magnusson
2014-11-23 19:57           ` TRY_BLOCK_ERROR and exit status Bart Schaefer
2014-11-24 10:11             ` Peter Stephenson
2014-11-25  8:01               ` Bart Schaefer [this message]
2014-11-25  9:18                 ` Peter Stephenson
2014-11-23 18:13         ` BUG: failure in "vcs_info prompt" aborts precmd function Bart Schaefer
2014-11-23 18:52           ` Mikael Magnusson
2014-11-23 19:47             ` Bart Schaefer
2014-11-23 22:03           ` Oliver Kiddle

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=141125000123.ZM17533@torch.brasslantern.com \
    --to=schaefer@brasslantern.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).