zsh-workers
 help / color / mirror / code / Atom feed
From: "Lawrence Velázquez" <larryv@zsh.org>
To: "Bart Schaefer" <schaefer@brasslantern.com>,
	"Philippe Altherr" <philippe.altherr@gmail.com>
Cc: zsh-workers@zsh.org
Subject: Re: [PATCH] Fix ERR_EXIT behavior in function calls and "always" statements
Date: Mon, 21 Nov 2022 02:22:38 -0500	[thread overview]
Message-ID: <230a78bb-fa97-4f3a-94a2-86982316274b@app.fastmail.com> (raw)
In-Reply-To: <CAH+w=7ZLr8R_pQfpcAdHiNyYH0K_A8ha815nz1zPBakYmCJ6Dg@mail.gmail.com>

On Sun, Nov 20, 2022, at 7:43 PM, Bart Schaefer wrote:
> Question for the wider list:  With this patch, anonymous functions
> behave like functions with respect to ERR_EXIT.  This is reasonable,
> but it does mean that
>
> set -e
> { { false && true } } # does not exit
> () { { false && true } } # exits
>
> Are we all OK with this

I am not sure.

On the one hand, it's consistent for anonymous functions to behave
like functions here, as they do in other respects.

On the other hand, this behavior violates the general idea that
complex commands shouldn't cause early exits due to ignored nonzero
exit statuses bubbling up from inside.  While anonymous functions
aren't listed as complex commands in the documentation, they certainly
aren't simple commands.  Function calls pop the bubbles (so to
speak) because they are simple commands, not because there's anything
particularly special about functions.  This suggests that anonymous
functions should *not* behave like normal function calls here.

So yeah, I don't know.


> Frankly I'm
> still not certain that the extra level of { } should matter in the
> function example.

Does it?  These seem to behave identically with Philippe's latest
patches; am I overlooking something?

	% Src/zsh -ec '() { { false && true } }; echo done'; echo $?
	1
	% Src/zsh -ec '() { false && true }; echo done'; echo $? 
	1


-- 
vq


  reply	other threads:[~2022-11-21  7:25 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-16 14:40 Philippe Altherr
2022-11-19 13:39 ` Philippe Altherr
2022-11-21  0:43   ` Bart Schaefer
2022-11-21  7:22     ` Lawrence Velázquez [this message]
2022-11-22  2:52       ` Philippe Altherr
2022-11-22  4:51         ` Bart Schaefer
2022-11-22 10:17         ` Peter Stephenson
2022-11-23  8:11           ` Lawrence Velázquez
2022-11-23  6:59         ` Lawrence Velázquez
2022-11-23  9:43           ` Philippe Altherr
2022-11-23 16:11             ` Bart Schaefer
2022-11-23 20:57               ` Submitting multiple patches (was: Re: [PATCH] Fix ERR_EXIT behavior in function calls and "always" statements) Daniel Shahaf
2022-11-23 21:11                 ` Bart Schaefer
2022-11-23 21:22                   ` Bart Schaefer
2022-11-23 21:54                   ` Bart Schaefer
2022-11-24  2:21                     ` Philippe Altherr
2022-11-26  2:28                       ` Bart Schaefer
2022-11-26  4:02                         ` Philippe Altherr
2022-11-24  1:47               ` [PATCH] Fix ERR_EXIT behavior in function calls and "always" statements Philippe Altherr
2022-11-24  4:28             ` Lawrence Velázquez

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=230a78bb-fa97-4f3a-94a2-86982316274b@app.fastmail.com \
    --to=larryv@zsh.org \
    --cc=philippe.altherr@gmail.com \
    --cc=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).