On Tue, Aug 14, 2012 at 1:36 AM, Roland Mainz <roland.ma...@nrubsig.org> wrote: > 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 ?
Here is a slightly easier example. No output on stderr should appear: -- snip -- 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 [[ "${.sh.match[2][j]-}" == '' || "${.sh.match[3][j]-}" == '' ]] && \ print -u2 -f "# No data, j=%d, .sh.match[2][j]=%q, .sh.match[3][j]=%q\n" \ j "${.sh.match[2][j]-}" "${.sh.match[3][j]-}" 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 [[ "${.sh.match[4][j]-}" == '' || "${.sh.match[5][j]-}" == '' ]] && \ print -u2 -f "# No data, j=%d, .sh.match[4][j]=%q, .sh.match[5][j]=%q\n" \ j "${.sh.match[4][j]-}" "${.sh.match[5][j]-}" 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 [[ "${.sh.match[6][j]-}" == '' || "${.sh.match[7][j]-}" == '' ]] && \ print -u2 -f "# No data, j=%d, .sh.match[6][j]=%q, .sh.match[7][j]=%q\n" \ j "${.sh.match[6][j]-}" "${.sh.match[7][j]-}" c.attrs+=( name="${.sh.match[6][j]}" value="${.sh.match[7][j]}" ) fi done print -v c -- snip -- ksh93v- currently prints... -- snip -- # No data, j=0, .sh.match[2][j]='', .sh.match[3][j]='' -- snip -- ... on stderr for this testcase... ---- 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