Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: ksh compatibility experts (extendedglob bareglobqual)
- X-seq: zsh-users 14576
- From: "Jerry Rocteur" <macosx@xxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: ksh compatibility experts (extendedglob bareglobqual)
- Date: Tue, 17 Nov 2009 12:34:28 +0100 (CET)
- Cc: "Peter Stephenson" <pws@xxxxxxx>
- Importance: Normal
- In-reply-to: <200911171016.nAHAGrTv004753@xxxxxxxxxxxxxx>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <58942.153.98.68.197.1258450547.squirrel@xxxxxxxxxxxxxxxxxxx> <200911171016.nAHAGrTv004753@xxxxxxxxxxxxxx>
> "Jerry Rocteur" wrote:
>> We're running in ksh compatibility mode (ksh linked to zsh)
>>
>> What I'd like to do is to write some scripts that make use of Extended Glob a
>> nd Glob qualifiers!
>>
>> I'd like to run something like this:
>>
>> #!/usr/bin/ksh
>>
>> setopt extendedglob
>> setopt bareglobqual
>>
>> touch cc.log
>> ls (cc|fi).log(N)
>> ls cc.log
>>
>>
>> But I have the setopt wrong cause I get this:
>>
>> ./try.ksh
>> ls: (cc|fi).log(N): No such file or directory
>> cc.log
>
> You need to "unsetopt shglob". This reenables bare parentheses. (I
> managed to get this to work after "emulate ksh", but for some reason not
> if I used ARGV0=ksh; I haven't worked out the difference.)
>
> Alternatively, you can use ksh globbing syntax:
>
> ls @(cc|fi).log(N)
>
> This works with glob qualifiers as long as bareglobqual is on.
Thanks Peter, this is even BETTER than I ever imagined!
1) We get to keep ksh compatibility by doing: @(cc|fi).log
2) We just have to add setopt bareglobqual and we get the zsh magic (N)
Thanks very much this is fantastic.. I'm going to have a bit of fun testing other things!
Cheers,
Jerry
Messages sorted by:
Reverse Date,
Date,
Thread,
Author