On Fri, Aug 9, 2013 at 1:00 AM, David Korn <[email protected]> wrote:
> cc: [email protected]
> Subject: Re: [ast-developers] typeset in signal trap ==> compound array
> contains typeset statements
> --------
>
>> Can anyone explain why the following code contains FOUR array elements
>> instead of two? I'm getting desperate with this. I only want to
>> declare c.car[index].int as a integer variable (aka typeset -li) but
>> receive this garbage instead when running it with ast-ksh.20130807:
>>
>> ksh -c 'set -o nounset ; compound c ; compound -a c.car; integer
>> c.cari=0; trap "typeset -i c.car[c.cari++].int=\${.sh.sig.value.int}"
>> RTMIN RTMAX ; kill -q4 -s RTMIN $$ ; true ; kill -q17 -s RTMAX $$ ;
>> true ; print -v c'
>> (
>> typeset -C -a car=(
>> [0]=(
>> int=4
>> )
>> [1]=(
>> typeset -i int=0
>> )
>> [2]=(
>> int=17
>> )
>> [3]=(
>> typeset -i int=0
>> )
>> )
>> typeset -l -i cari=4
>> )
>>
>> Ced
>> --
>> Cedric Blancher <[email protected]>
>> Institute Pasteur
>>
>
> I can explain why it is happening, but I haven't decided how to resolve it.
>
> typeset foo=bar
> is parsed as if it is
> foo=bar typeset foo
>
> However since you have
> typeset foo[i++]=bar
> this becomes
> foo[i++]=bar typeset foo[i++]
this is wrong because i++ would be evaluated twice
>
> Your workaround is to do
> typeset -i c.car
> before the trap and do
> trap "tc.car[c.cari++].int=\${.sh.sig.value.int}"
> for the trap.
This doesn't work. How is it supposed to work in your opinion?
Irek
_______________________________________________
ast-developers mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-developers