Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Exporting arrays



Adam Spiers <adam@xxxxxxxxxxxxxxxxxxxxxxx> typed:
:% foo=(a b c)
:% typeset | grep zzz
:array foo=(a b c)
:% export foo=(a b c)
:% typeset | grep zzz 
:array exported foo=(a b c)
:However,
:
:% unset foo
:% export foo=(a b c)
:% typeset | grep zzz 
:exported foo='(a b c)'
:Presumably there's a decent reason for this behaviour; would
:someone be good enough to explain it to me?

One important thing to note is that there is no defined method for exporting
arrays.  You can only export text strings.  In the first case, even though it 
says 'array exported foo=(a b c)' it won't be exported as anything, though
it will be used in the current shell as an array.  In the second, well, 
you haven't previously told it that foo is an array but you've said you
want to export it, so it'll make it something it can export, ie. a string.
-- 
Geoff Wing [gcw@xxxxxxxxx]                         Phone    : +61-3-9818 2977
 Technical Manager: PrimeNet Computer Consultants  Facsimile: +61-3-9818 5155
 Work URL: http://www.primenet.com.au/             Mobile   : 0412 162 441
 Ego  URL: http://pobox.com/~gcw/



Messages sorted by: Reverse Date, Date, Thread, Author