help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: access exported var


From: Chet Ramey
Subject: Re: access exported var
Date: Mon, 16 Jan 2023 13:02:47 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.6.1

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 lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]