help-bash
[Top][All Lists]
Advanced

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

Re: access exported var


From: Lawrence Velázquez
Subject: Re: access exported var
Date: Mon, 16 Jan 2023 01:28:16 -0500
User-agent: Cyrus-JMAP/3.7.0-alpha0-1187-g678636ba0d-fm-20230113.001-g678636ba

On Mon, Jan 16, 2023, at 1:05 AM, Kerin Millar wrote:
> On Sun, 15 Jan 2023 23:59:54 -0600
> Peng Yu <pengyu.ut@gmail.com> wrote:
>
>> But `echo "$Z"` print "a". Why bash can not treat exporting array as
>> exporting the first element?
>
> Technically, that would be possible.

For what it's worth, ksh exports indexed arrays that way, while zsh
behaves like bash (i.e., does not export), and yash synthesizes a
PATH-style scalar.  (Of course, dash and POSIXly-correct yash don't
support arrays.)

        % cat export_array.sh
        foo=(a b c)
        export foo
        env | grep foo
        % bash export_array.sh
        % ksh export_array.sh
        foo=a
        % zsh export_array.sh
        % yash export_array.sh
        foo=a:b:c
        % ARGV0=sh yash export_array.sh
        export_array.sh:1: syntax error: invalid use of `('
        % dash export_array.sh
        export_array.sh: 1: Syntax error: "(" unexpected

-- 
vq



reply via email to

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