[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: for i[1] in ...
From: |
Chet Ramey |
Subject: |
Re: for i[1] in ... |
Date: |
Mon, 26 Nov 2001 12:35:52 -0500 |
> $ m=(a b c);echo ${m[@]}
> a b c
> $ export m=(a b c);echo ${m[@]}
> (a b c) b c
It's sort of a congruence of features.
Since you can't export arrays, export doesn't understand the compound
assignment syntax. export treats the above as assigning the string
`(a b c)' to the variable `m'.
Assigning to a variable that is already an array without a subscript
is the same as assigning to element 0.
This is, I agree, less consistent than it could (should) be.
> 0bin$ export p=(a b c);echo ${p[@]}
> (a b c)
This actually does the same thing, appearances aside. `p' is actually
a variable whose value is `(a b c)'. The ability to understand array
notation for non-array variables was added for ksh93 compatibility some
time ago.
> $ set -v
> $ z=w
> z=w
> $ m=(1 v)
> m=(1 v)
> 1 v
> odd, 2 lines not one.
It's an artifact of the implementation. I'll fix it. Thanks.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet)
Chet Ramey, CWRU chet@po.CWRU.Edu http://cnswww.cns.cwru.edu/~chet/
- for i[1] in ..., Dan Jacobson, 2001/11/25
- Re: for i[1] in ...,
Chet Ramey <=