zsh-users
 help / color / mirror / code / Atom feed
From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: zmv exits from function
Date: Tue, 2 Jan 2024 10:16:43 -0800	[thread overview]
Message-ID: <30a2a6d7-5125-4d9d-a95d-9f110bd736f0@eastlink.ca> (raw)
In-Reply-To: <CAA=-s3zQPn4kWCY2zE0jK8KdqRZbzF_ZDTH1pdKv8208ad_tkw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1874 bytes --]


On 2024-01-02 09:47, Mark J. Reed wrote:
>
>
> https://zsh.sourceforge.io/Doc/Release/Shell-Grammar.html#Complex-Commands
>
Thanks.  Man, I wish there were more examples :(


> Well, no.  It runs the code on the left, and then when it finishes it 
> runs the code on the right. That's the extent of the `always` 
> functionality. What makes it special is that the code on the right 
> runs even if the code on the left blows up somehow.
Yeah, I think I get it.  But the 'memo' has to be there -- zmv must ... 
or maybe not ... when zmv returns, if the 'always' keyword (sorta) it 
there, then it knows to not crash but to execute the following code.  
So, yeah, it could be seen as 'linear'.
>
> It's similar to a feature called the "finally block" in other 
> languages, where it's usually attached to the exception-handling 
> mechanism; something like `try { start here } catch (ErrorType) { do 
> this if the previous block failed this particular way } finally { run 
> this no matter what }`.  Because of that similarity, the code on the 
> left of the `always` is called the "try block" or "try list", even 
> though zsh doesn't use the keyword "try". The code on the right is 
> called the "always block" or "always list".
That's interesting.  So this isn't some desperate hack -- that kind of 
functionality is standard to some degree.  Ok, good to know. But as I 
said, it sure looks strange the first time you see it.  Reading a bit 
more, I see it's got other uses than preventing meltdowns. Cool.
>
> If you want the world not to be blown up, you can set TRY_BLOCK_ERROR 
> to 0, and then zsh will forget that anything went wrong and continue 
> about its business.

I myself hardly ever want Ragnarok, so next time I run into this sort of 
issue, I've got that to defuse it.  Thanks Mark.  Hey, I wonder if that 
could be an option? NO_MELTDOWNS=on


[-- Attachment #2: Type: text/html, Size: 3607 bytes --]

  reply	other threads:[~2024-01-02 18:17 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-30 17:42 Ray Andrews
2023-12-30 20:38 ` Bart Schaefer
2023-12-30 21:02   ` Ray Andrews
2023-12-30 22:21     ` Bart Schaefer
2023-12-30 21:15   ` Mikael Magnusson
2023-12-31  3:43     ` Ray Andrews
2023-12-31  3:58       ` Bart Schaefer
2023-12-31 15:53         ` Ray Andrews
2023-12-31 21:44           ` Bart Schaefer
2023-12-31 22:06             ` Ray Andrews
2024-01-02 14:51               ` Mark J. Reed
2024-01-02 17:01                 ` Ray Andrews
2024-01-02 11:50   ` Peter Stephenson
2024-01-02 17:08     ` Ray Andrews
2024-01-02 17:47       ` Mark J. Reed
2024-01-02 18:16         ` Ray Andrews [this message]
2024-01-02 20:24           ` Bart Schaefer
2024-01-02 21:32             ` Ray Andrews
2024-01-02 17:48       ` Peter Stephenson
2024-01-02 19:07         ` Bart Schaefer
2024-01-02 19:52           ` Ray Andrews
2024-01-03  9:55           ` Peter Stephenson
2024-01-03 15:46             ` Ray Andrews
2024-01-03 19:01               ` Bart Schaefer
2023-12-30 22:34 ` Bart Schaefer

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=30a2a6d7-5125-4d9d-a95d-9f110bd736f0@eastlink.ca \
    --to=rayandrews@eastlink.ca \
    --cc=zsh-users@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).