zsh-users
 help / color / mirror / code / Atom feed
* ksh compatibility experts (extendedglob bareglobqual)
@ 2009-11-17  9:35 Jerry Rocteur
  2009-11-17 10:16 ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Jerry Rocteur @ 2009-11-17  9:35 UTC (permalink / raw)
  To: zsh-users

Hi,

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


Does anyone know how to get ls (cc|fi).log(N) working in compatibility mode, i.e. which option must I overwrite for
this to work ?

Thanks in advance,

Jerry


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: ksh compatibility experts (extendedglob bareglobqual)
  2009-11-17  9:35 ksh compatibility experts (extendedglob bareglobqual) Jerry Rocteur
@ 2009-11-17 10:16 ` Peter Stephenson
  2009-11-17 11:34   ` Jerry Rocteur
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2009-11-17 10:16 UTC (permalink / raw)
  To: zsh-users

"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@csr.com>            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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: ksh compatibility experts (extendedglob bareglobqual)
  2009-11-17 10:16 ` Peter Stephenson
@ 2009-11-17 11:34   ` Jerry Rocteur
  0 siblings, 0 replies; 3+ messages in thread
From: Jerry Rocteur @ 2009-11-17 11:34 UTC (permalink / raw)
  To: zsh-users; +Cc: Peter Stephenson

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-11-17 23:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-17  9:35 ksh compatibility experts (extendedglob bareglobqual) Jerry Rocteur
2009-11-17 10:16 ` Peter Stephenson
2009-11-17 11:34   ` Jerry Rocteur

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).