Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: zmv exits from function
- X-seq: zsh-users 29389
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: Ray Andrews <rayandrews@xxxxxxxxxxx>, Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: zmv exits from function
- Date: Sat, 30 Dec 2023 22:15:28 +0100
- Archived-at: <https://zsh.org/users/29389>
- In-reply-to: <CAH+w=7YUYK+2wg+r4yuxieBY6D4epwvi3sPYrs6tcWJk6GwKbw@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <69024621-9e60-474f-9c32-4edaecc3ff68@eastlink.ca> <CAH+w=7YUYK+2wg+r4yuxieBY6D4epwvi3sPYrs6tcWJk6GwKbw@mail.gmail.com>
On 12/30/23, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Sat, Dec 30, 2023 at 9:43 AM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>>
>> I'm using zmv to rename files in a directory tree recursively via a
>> 'for' loop which visits each subdirectory. It works fine if there are
>> files found to rename, but if not, then the entire function crashes back
>> to CL. How can I persuade zmv to just let the function cycle to the
>> next subdir?
>
> zmv forces zsh emulation which means the nomatch option is in effect,
> and you can't change that without editing the zmv source.
>
> Just run the zmv in a subshell:
>
> ( zmv '(*).SNT' '$1.eml' )
> ( zmv '(*).MES' '$1.eml' )
You can also do this:
{ zmv '(*).SNT' '$1.eml' } always { TRY_BLOCK_ERROR=0 }
I have this aliased as
alias always_continue='always { TRY_BLOCK_ERROR=0 }'
which lets you do the slightly neater
{ zmv '(*).SNT' '$1.eml' } always_continue
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author