On Wed, Apr 11, 2012 at 22:05, David Korn <[email protected]> wrote:

> cc: [email protected]
> Subject: Re: [ast-users] [ksh93] [[ == ]] does not update ${.sh.match}?
> --------
>
> > See following example:
> >
> > $ echo ${.sh.version}
> > Version jM 93u 2011-02-08
> > $
> > $ [[ foo == foo* ]] && echo matched
> > matched
> > $ typeset -p .sh.match
> > typeset -a .sh.match=(foo)    <== this is fine
> > $
> > $ [[ bar == bar ]] && echo matched
> > matched
> > $ typeset -p .sh.match
> > typeset -a .sh.match=(foo)    <== it's not updated
> > $
> >
>
> .sh.match only gets set for pattern matches, not for string matches.
> If the right hand side does not contain any of the special pattern
> characters, it will do a string match.  Using douoble quotes around
> the right hand operand will do a string match.
>

But the behavior is not consistent with the =~ operator:

$ echo ${.sh.version}
Version jM 93u 2011-02-08
$ [[ foo =~ foo ]]
$ ts -p .sh.match
typeset -a .sh.match=(foo)
$ [[ bar =~ 'bar' ]]    <== The right hand operand is quoted so it's a
string match
$ ts -p .sh.match
typeset -a .sh.match=(bar)    <== but .sh.match is updated here.
$

>
> David Korn
> [email protected]
>
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to