[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: access exported var
From: |
Kerin Millar |
Subject: |
Re: access exported var |
Date: |
Mon, 16 Jan 2023 05:58:53 +0000 |
On Sun, 15 Jan 2023 23:37:41 -0600
Peng Yu <pengyu.ut@gmail.com> wrote:
> On 1/15/23, Lawrence Velázquez <vq@larryv.me> wrote:
> > On Mon, Jan 16, 2023, at 12:10 AM, Peng Yu wrote:
> >> The results are different depending on whether the variable is a
> >> scalar or an array (the result is always null). Why is it so?
> >
> > Because arrays cannot be exported to the environment.
>
> If that is the case, why bash does not print an error message?
I suspect it's not worth the bother. Should the second of these two commands
produce an error or refuse to convert "a" to an array?
$ export a=1
$ a=(2 3)
You can probably imagine other cases where similar questions would need to be
posed.
As it stands, the exportable attribute is set for the variable - it can be seen
with declare -p var or with "${var@a}" - but simply not acted upon if it's an
array. For what it is worth, it's mentioned in the BUGS section. I suppose it
might be helpful to mention it elsewhere (it might be, but I didn't look too
hard).
--
Kerin Millar
Re: access exported var, Chet Ramey, 2023/01/16
Re: access exported var, Lawrence Velázquez, 2023/01/16