help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] indirection for arrays


From: Chet Ramey
Subject: Re: [Help-bash] indirection for arrays
Date: Wed, 09 May 2012 09:07:22 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:11.0) Gecko/20120327 Thunderbird/11.0.1

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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
http://austingroupbugs.net/view.php?id=351#c865 .

Chet
- -- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk+qbAkACgkQu1hp8GTqdKvBFQCfWD/kw4G3f9wBhWddZMj1BXvm
AlgAn0o6MvoGXCGqQKNbhY/qoCjApIuY
=mXXg
-----END PGP SIGNATURE-----



reply via email to

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