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

Should VAR[n]=val cmd export VAR?



The option ALL_EXPORT (-a) is described as automatically exporting all parameters subsequently defined. This extends to parameters subsequently assigned, including ones with a subscript:

% zsh -c 'typeset VAR=123; set -a; VAR[2]=X; set +a; typeset -p VAR; printenv VAR'              
export VAR=1X3
1X3

Inline assignments export the assigned parameters (with or without ALL_EXPORT option) but in that case parameters with a subscript are excluded:

% zsh -c 'typeset VAR=123; VAR[2]=X typeset -p VAR; VAR[2]=X printenv VAR'
typeset VAR=1X3


This discrepancy looks strange to me. I expected that "VAR[n]=val cmd" would export VAR. I find the lack of export even stranger given that "VAR[n]=val" exports VAR when ALL_EXPORT is enabled.

Wdyt? Could we change inline assignments to also export parameters with a subscript?

Philippe



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