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.

-- 
Peter Stephenson <pws@xxxxxxx>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom



Messages sorted by: Reverse Date, Date, Thread, Author