Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: array bug
- X-seq: zsh-workers 8636
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- To: Dave Gaulke <gaulke@xxxxxxxxxx>, zsh-workers@xxxxxxxxxxxxxx
- Subject: Re: array bug
- Date: Sun, 14 Nov 1999 17:09:35 +0000
- In-reply-to: <19991113194512.A15965@xxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
- References: <19991113194512.A15965@xxxxxxxxxxxxxxxxxxxxxx>
On Nov 13, 7:45pm, Dave Gaulke wrote:
} Subject: array bug
}
} function arrtest
} {
} set -A myarray
} typeset -x myarray
} myarray[1]=arrtest
} print ${myarray[1]}
} }
}
} When I run this it prints only "a" and not the expected "arrtest".
This is not the bug you think it is.
"set -A myarray" is declaring a *global* (not local to "arrtest") array
named "myarray". It's exactly equivalent to writing
myarray=()
"typeset -x myarray" then declares a local scalar, also named "myarray",
which hides the global. This is a result of a recent change that makes
"export" equivalent to "typeset -gx" and not equivalent to "typeset -x".
This is a known bug. For the time being, you should use "export" when
you mean "export".
function arrtest
{
set -A myarray
export myarray
myarray[1]=arrtest
print $myarray
}
However, since arrays can't be exported in the first place (zsh marks
them exported internally, but does not put them in the environment) it's
almost certainly the case that you shouldn't have used "typeset -x" in
the first place.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Messages sorted by:
Reverse Date,
Date,
Thread,
Author