On 1/16/23, Chet Ramey <chet.ramey@case.edu> wrote:
> On 1/16/23 12:58 PM, Peng Yu wrote:
>> If that is the case, for the same reason, why $Z returns the first
>> element of the array Z?
>
> Korn put that in for backwards compatibility, so you could change a
> variable that previously had a meaning into an array and not have to
> change existing scripts. FUNCNAME is a bash example here. That has
> value. Exporting an array as its first element doesn't; it's simply an
> undesirable side effect.
>
>> If $Z returns the first element of the array
>> Z, then it would be surprising that export Z does not make the first
>> element available in the environment.
>
> Except for everyone who says "I exported the array, why do I only get
> the first element?"
The real question should be the following.
Given arrays cannot be exported, is it better to export nothing or
export the first element?
--
Regards,
Peng