Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: ksh compatibility experts (extendedglob bareglobqual)



> "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