zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh-workers@zsh.org
Subject: Re: Function code breaking out of if then ...fi
Date: Mon, 05 Nov 2012 14:55:01 +0000	[thread overview]
Message-ID: <20121105145501.50c674f1@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <20121105142942.41d73d31@pwslap01u.europe.root.pri>

On Mon, 05 Nov 2012 14:29:42 +0000
Peter Stephenson <p.stephenson@samsung.com> wrote:
> It's not really like a break, it's like (well, is) a global error flag
> --- but the error status gets reset at the top level command loop,
> which we reach in a script after the end of a set of complex commands
> --- but only right at the end, when we're reading a new (possibly
> complex, arbitrarily nested) command from the script.
> 
> I think actually what's going on could be considered a bug which is an
> oversight for the case of scripts.

Hmmm... there are multiple loops here and they have different error
handling.

In loop(),

	if (((!interact || sourcelevel) && errflag) || retflag)
	    break;

This actually does what I want: if it's not interactive, and there's an
error, break out of the loop.  This is the "top level" loop I was
thinking of.

However, there are two even topper level loops in zsh_main().  They
appear to be limited to handling the case of hitting EOF and a parse
error --- no other sort of error --- however, and aren't restricted to
interactive behaviour.  I don't really like the look of the combination
of these three loops --- it smells to me like the effect hasn't been
thought through properly.  I can see you need to exit if you've got a
parse error, because you don't know what to execute yet, but I don't see
that you need to ignore all other errors in the outer loops.  retflag
and sourcelevel are irrelevant out here but I can definitely see a
case for "if (!interact && errflag) /* exit */".

pws


  reply	other threads:[~2012-11-05 14:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-02  9:09 Michal Maruska
2012-11-02 21:39 ` Bart Schaefer
2012-11-05  8:22   ` Han Pingtian
2012-11-05  9:31     ` Han Pingtian
2012-11-05 14:29   ` Peter Stephenson
2012-11-05 14:55     ` Peter Stephenson [this message]
2012-11-05 16:08       ` Peter Stephenson
2012-11-06  6:47         ` Han Pingtian
2012-11-09 22:52       ` Peter Stephenson
2012-11-10  1:13         ` Bart Schaefer
2012-11-10 21:23           ` Peter Stephenson
2012-11-12 10:24             ` Peter Stephenson

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=20121105145501.50c674f1@pwslap01u.europe.root.pri \
    --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).