Re: Problem with using extended filename globbing in Ksh

From: Eric Haijun Xu (eric.xhj_at_gmail.com)
Date: 11/29/05


Date: 28 Nov 2005 22:41:35 -0800

danr wrote:
> danr wrote:
> > To protect the asterisks in the assighnment, it's advisable to use
> > quotes.
> > PPPOE='DIAL_*2005@(092[2-9]|093[01]|10[01][0-9]|102[01])*'
> ....
> > eval ls "$SD$PPPOE"
> >
> As Chris Johnson pointed out, I was wrong about needing the quotes in
> your assignment statement. If your re had embedded tabs or multiple
> whitespace substrings then (of course) the quotes would be needed.
> However, I still stand by the "eval" :-)
>
> Regards,
> Dan R.
Thanks for Chris and Dan

I just do a little experiment:
---------------------------------
$ touch good bad
$ y=*
$ print $y
bad good
$ print "$y"
*
$ print ${y}
bad good

$ y=@(bad|good)
$ print $y
@(bad|good)
$ print "$y"
@(bad|good)
$ print ${y}
@(bad|good)
$ eval print "$y"
bad good
---------------------------------
There is no simple guideline for this, but if you have 'eval' to ensure
expected globbing.