[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] declare -i
From: |
Chet Ramey |
Subject: |
Re: [Help-bash] declare -i |
Date: |
Thu, 10 May 2012 08:14: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 5:20 PM, Dan Douglas wrote:
> But this is probably a bug:
>
> $ a=(1 2 3); f() { local a=(a b c); declare -ga a+=(4); declare -p a; }; f;
> declare -p a
> -bash: declare: `a+': not a valid identifier
> declare -a a='([0]="a" [1]="b" [2]="c" [3]="4")'
> declare -a a='([0]="1" [1]="2" [2]="3")'
Maybe. ksh93 doesn't like it, either.
>
> Most of the anomolies aren't necessarily "bugs", just undocumented or
> conflict
> with documented things. One is that += can unset the zeroth element in Bash
> if
> the index isn't given explicitly. += doesn't unset elements in any other case.
Yeah, that's a bug. A case of a bare `a' not being treated as equivalent
to a[0] in every context.
> Another the manual doesn't mention is that negative indexes can't be used on
> assignment, even if the array already exists (ksh can, but zsh and mksh
> completely disagree here too):
The number of things that the manual does not mention that bash can't do
is infinite.
- --
``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+rsR4ACgkQu1hp8GTqdKvN/ACgnQV8aMLlklVke+8+U+RAhQFl
JM8AniRc7vfxEqC7EWvaBkv3I1TGgJXY
=Egu5
-----END PGP SIGNATURE-----
- Re: [Help-bash] declare -i, (continued)
- Re: [Help-bash] declare -i, Bill Gradwohl, 2012/05/10
- Re: [Help-bash] declare -i, Clark WANG, 2012/05/09
- Re: [Help-bash] declare -i, Chet Ramey, 2012/05/09
- Re: [Help-bash] declare -i, lxnf98mm, 2012/05/09
- Re: [Help-bash] declare -i, Greg Wooledge, 2012/05/09
- Re: [Help-bash] declare -i, Dan Douglas, 2012/05/09
- Re: [Help-bash] declare -i,
Chet Ramey <=