[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] indirection for arrays

From: Dan Douglas
Subject: Re: [Help-bash] indirection for arrays
Date: Wed, 09 May 2012 09:26:03 -0500
User-agent: KMail/4.8.3 (Linux/3.3.4-pf+; KDE/4.8.3; x86_64; ; )

On Wednesday, May 09, 2012 09:07:22 AM Chet Ramey wrote:
> On 5/9/12 3:42 AM, Dan Douglas wrote:
> > Not random. The same behavior affects this more common construct:
> >  ~ $ x=y; y=(1 2 3); declare -a "$x"+=(a b c); declare -p y
> > 
> > -bash: syntax error near unexpected token `('
> > 
> > One would need to know that this triggers declare to treat args as
> > ordinary
> > args and to quote the entire thing as such.
> The idea is to treat declare -attribute x=y the same way you would treat
> declare -attribute x; x=y
> If you want to know whether or not a particular argument will be treated
> as an assignment statement, ask yourself whether it would stand alone as
> an assignment statement.
> Posix has taken an initial pass at specifying this behavior; look at
> .
> Chet

Ah Thanks, I already saw that bug but reading it again I see it pretty well 
describes what's going on here.

I suspect the current way of serializing arrays is going to be a complete 
train wreck anyway once shells that don't want to add OO extensions (i.e. 
typeset name=(typeset ...)) do want to  add multidimensional arrays that 
support mixed indexed and associative arrays. Mksh is thinking about adding 
JSON to work around this... ugh what a mess.
Dan Douglas

reply via email to

[Prev in Thread] Current Thread [Next in Thread]