Hi!

----

AFAIK the following test script...
-- snip --
integer j k
compound c
compound -a c.attrs

attrdata=$' x=\'1\' y=\'2\' z="3" end="world"'

dummy="${attrdata//~(Ex-p)(?:
        [[:space:]]+
        ( # four different types of name=value syntax
                (?:([:_[:alnum:]-]+)=([^\"\'[:space:]]+?))|     #x='foo=bar 
huz=123'
                (?:([:_[:alnum:]-]+)=\"([^\"]*?)\")|            #x='foo="ba=r 
o" huz=123'
                (?:([:_[:alnum:]-]+)=\'([^\']*?)\')|            #x="foox 
huz=123"
                (?:([:_[:alnum:]-]+))                           #x="foox 
huz=123"
        )
        )/D}"


for (( j=0 ; j < ${#.sh.match[0][@]} ; j++ )) ; do
        if [[ -v .sh.match[2][j] && -v .sh.match[3][j] ]] ; then
                c.attrs+=( name="${.sh.match[2][j]}" value="${.sh.match[3][j]}" 
)
        fi ; if [[ -v .sh.match[4][j] && -v .sh.match[5][j] ]] ; then
                c.attrs+=( name="${.sh.match[4][j]}" value="${.sh.match[5][j]}" 
)
        fi ; if [[ -v .sh.match[6][j] && -v .sh.match[7][j] ]] ; then
                c.attrs+=( name="${.sh.match[6][j]}" value="${.sh.match[7][j]}" 
)
        fi
done

print -v c
-- snip --
... should print...
-- snip --
(
        typeset -a attrs=(
                [0]=(
                        name=x
                        value=1
                )
                [1]=(
                        name=y
                        value=2
                )
                [2]=(
                        name=z
                        value=3
                )
                [3]=(
                        name=end
                        value=world
                )
        )
)
-- snip --
... but ast-ksh.2012-08013 (ksh93v- alpha) prints this:
-- snip --
-- snip --
(
        typeset -a attrs=(
                [0]=(
                        name=''
                        value=''
                )
                [1]=(
                        name=x
                        value=1
                )
                [2]=(
                        name=y
                        value=2
                )
                [3]=(
                        name=z
                        value=3
                )
                [4]=(
                        name=end
                        value=world
                )
        )
)
-- snip --

The extra  "[0]=(  name='' value='' )" seems to come from the issue
that [[ -v .sh.match[2][j] && -v .sh.match[3][j] ]] returns "true"
while there should be no matches for the corresponding pattern... or
am I somehow wrong ?

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) roland.ma...@nrubsig.org
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 3992797
 (;O/ \/ \O;)
_______________________________________________
ast-developers mailing list
ast-developers@research.att.com
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to