Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Questions from zshexpn(1) -- Globbing
- X-seq: zsh-users 24448
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: <zsh-users@xxxxxxx>
- Subject: Re: Questions from zshexpn(1) -- Globbing
- Date: Tue, 19 Nov 2019 09:35:03 +0000
- Cms-type: 201P
- Dkim-filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20191119093505euoutp0202382eaf51b91d3c50680e70b62879e1~YhqMngJtj0392503925euoutp02K
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1574156105; bh=QY2RKOvrLep3Faf1qwO7NGSQLsC0FC8oBdyfUQRNmE0=; h=Subject:From:To:Date:In-Reply-To:References:From; b=qXy3YoyhGopvRrENrhr+H+fzk+07DKODisXIJl3CP34ng9b1sfN40w41a4CZG/qHh drkMNibIn1nH7/J9Xb8ahYXmwoySquWqNrSkVbTOrSKWnvIR02d1Tn3jntxCofMVsx a72G4l+53nMS15ydf5LYe/Vys25G5PezgmClBHUo=
- In-reply-to: <F1AE3C36-D2A2-4F76-9B02-E92B8AAE4FA9@easesoftware.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CGME20191119005526eucas1p2f346934679a40e37d2424b3ab6df4cbc@eucas1p2.samsung.com> <F1AE3C36-D2A2-4F76-9B02-E92B8AAE4FA9@easesoftware.com>
On Mon, 2019-11-18 at 18:53 -0600, Perry Smith wrote:
> The subsection is Globbing Flags within Filename Generation with both
> the b and m flags is a curious phrase:
>
>> Activate backreferences for parenthesised groups in the pattern;
>> this does not work in filename generation.
> Why does it say “this does not work in filename generation” ? Using
> their example for the m flag:
>
>> arr=(veldt jynx grimps waqf zho buck)
>> print ${arr//(#m)[aeiou]/${(U)MATCH}}
> I can change the “print” to “touch” and it touches the files and
> change it to “rm” and it removes the files.
>
> My fear here is that I’m missing something rather significant such as
> what precisely is “filename generation”
You're using that feature in variable substitution, not filename
generation.
Filename generation is specifically the use of pattern characters *, ?,
etc. to generate file names. So what this means is that the patterns
generated by that method aren't available for use in what I called
backreferences (that's a bad name, sorry: when used in regular
expressions, its standard meaning is references back to a previous part
of the same pattern, which isn't what's happening here).
So if instead of using the array you matched the files directly,
having created them:
touch $arr
print (#m)*([aeiou])*
you'd have no way of using the references generated because the file
names are substituted before the $MATCH variable would be available ---
which is probably obvious.
Of course, even if you needed to match the files on the disk first you
could still do
arr=(*)
print ${arr//(#m)[aeiou]/${(U)MATCH}}
so you've still got the ability to change the file names with variable
substitution.
So this is probably saying less than you think it is.
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author