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: Sat, 30 Dec 2023 19:43:37 -0800	[thread overview]
Message-ID: <07ddd352-0c1b-467e-9d4c-ff46020ccf41@eastlink.ca> (raw)
In-Reply-To: <CAHYJk3QW1Kv-137nrTN9up3ST3_mdDyeC3eLMLjK8HVUXv-OcA@mail.gmail.com>

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


On 2023-12-30 13:15, Mikael Magnusson wrote:
> You can also do this:
>    { zmv '(*).SNT' '$1.eml' } always { TRY_BLOCK_ERROR=0 }

Sheesh, of course I'm no expert, still I've never seen any such 
construction before.  Always new domains of syntax to study.  So when 
zmv quits, crashing out of the function is not immediate -- there is 
further parsing, thus this 'always' word is handled. Interesting.

On 2023-12-30 12:38, Bart Schaefer wrote:

> Arguably zmv could use null_glob.  Thoughts from -workers?

That's that option that makes everything grind to a halt if nothing if found?

> No, you're thinking of nomatch, which as I said is already in effect
and causing the result that you see.  The null_glob option supersedes
no_match and makes globs that don't match anything disappear without
an error.

Yeah, for some unknown reason I said it backwards -- I know that (N) smooths continuation of flow, it doesn't break it.

> This is in contrast to the no_nomatch option which leaves
the glob un-expanded but does not remove it.

I've run into that, and it can be ugly -- literal asterisks being fed to some command that doesn't want them.  It's good to understand what's going down there.

   Setting null_glob
globally can be dangerous because it can leave a command with no
arguments at all or with its arguments in a different order than
expected.

Yes, another potential landmine.  What might be intuitive is some way of simply making a command 'stop', but that might not be so simple -- something that holds it's place, but has no value -- it 'counts' as an argument but has no content.  It's so dumb when: "ls no-such-files.*" ends up listing everything in the directory rather than nothing.  Dunno who thought that was a good idea.


>  zmv -n '(*/)#(*).(SNT|MES)' '$1$2.eml'

If that looks like it would do the right thing, remove the "-n".

I'll give it a go.  So much can be done with all that globbing functionality.  Such power.  But I can never remember that tersest of all terse syntaxes -- gotta make myself a cheat sheet including a page full of examples.


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

  reply	other threads:[~2023-12-31  3:44 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 [this message]
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
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=07ddd352-0c1b-467e-9d4c-ff46020ccf41@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).