Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Parameter Expansion pattern compatibility
- X-seq: zsh-users 13581
- From: Stephane Chazelas <Stephane_Chazelas@xxxxxxxx>
- To: "@ Rocteur CC" <macosx@xxxxxxxxxx>
- Subject: Re: Parameter Expansion pattern compatibility
- Date: Wed, 10 Dec 2008 18:24:13 +0000
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <304B7520-9E2A-48C8-9673-FF8081A3E9C0@xxxxxxxxxx>
- Mail-followup-to: "@ Rocteur CC" <macosx@xxxxxxxxxx>, zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <60710.153.98.68.197.1228920251.squirrel@xxxxxxxxxxxxxxxxxxx> <20081210151936.GC4843@xxxxxxxxxxxxxxx> <304B7520-9E2A-48C8-9673-FF8081A3E9C0@xxxxxxxxxx>
On Wed, Dec 10, 2008 at 07:13:27PM +0100, @ Rocteur CC wrote:
[...]
>> That's ksh globbing syntax (except for the outer (...)). To
>> enable it in zsh, you need setopt kshglob.
>>
>> The zsh equivalent of @(...) is (...), the equivalent of *(x) is
>> x# (with extendedglob).
>>
>> ~$ setopt kshglob; echo ${userId##[pPRrTt]@([0-9]|[a-z])*([0-9])}
>> btu btu btu eb41 bt2 jro dri
>>
>> ~$ setopt nokshglob extendedglob; echo
>> ${userId##[pPRrTt]([0-9]|[a-z])[0-9]#}
>> btu btu btu eb41 bt2 jro dri
>
>
> OUCH, I tried those with no success so the problems were setopt and the
> outer ()
>
> I did try kshglob and I didn't think to remove the outer bracket. (I've
> just tried it on my home system and it works with the outer bracket ?
It works in zsh (as (...) are the same as ksh's @(...)), but
wouldn't in ksh. I'd expect you to get an error in ksh.
> This all happens in a massive script so I could put setopt kshgob within
> the function.
When zsh is called as "ksh", the kshglob option is activated.
> As always Stephane, thanks very much .. I really appreciate your help all
> the time!
>
> As an aside note, how would one do this in standard zsh without the kshglob
> ?
[...]
As I said:
The zsh equivalent of @(...) is (...), the equivalent of *(x) is
x# (with extendedglob).
~$ setopt nokshglob extendedglob; echo ${userId##[pPRrTt]([0-9]|[a-z])[0-9]#}
btu btu btu eb41 bt2 jro dri
You need the extendedglob.
Note that bash's extglob is actually a subset of ksh's extended
globbing operators. zsh's kshglob also is a subset, it doesn't
include the latest ones from latest versions of ksh93. zsh's
extendedglob has a few operators which ksh93 doesn't have such
as <x-y> for matching numbers.
--
Stéphane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author