On Tue, Oct 10, 2017 at 08:00:58AM -0400, shawn wilson wrote:
> I guess that's the right way to describe what I'm seeing:
> 
> [swilson@localhost ~]$ unset f; f=(aaa bbb ccc) declare -p f
> declare -x f="(aaa bbb ccc)"

You placed a string variable in the temporary execution environment of
the declare command.  If you wanted an actual array variable that would
persist past this command, you need a semicolon or newline after the
assignment, and before the declare command.

What you did:

wooledg:~$ unset f; f=(aaa bbb ccc) declare -p f
declare -x f="(aaa bbb ccc)"
wooledg:~$ declare -p f
bash: declare: f: not found

What you probably wanted:

wooledg:~$ unset f; f=(aaa bbb ccc); declare -p f
declare -a f=([0]="aaa" [1]="bbb" [2]="ccc")
wooledg:~$ declare -p f
declare -a f=([0]="aaa" [1]="bbb" [2]="ccc")

See also: http://mywiki.wooledge.org/BashFAQ/104

Reply via email to