|
From: | Chris F.A. Johnson |
Subject: | Re: [Help-bash] Why bash does not recoganize array type smartly? |
Date: | Thu, 10 Mar 2016 00:14:27 -0500 (EST) |
User-agent: | Alpine 2.10 (DEB 1266 2009-07-14) |
On Wed, 9 Mar 2016, Peng Yu wrote:
Hi, Bash requires one explicitly declare associative array before it can be used. It seems that this requirement may be too strictly given no other types need to be declared first before being used. Is there any rationale why bash is defined in this way. Wouldn't it better to allow users define associative array just by using something like `x=([a]=1 [b]=2)` without having to declare it?
Because a and b are read as variables.
x=([a]=1 [b]=2) declare -A x ./main.sh: line 6: declare: x: cannot convert indexed to associative array
-- Chris F.A. Johnson, <http://cfajohnson.com>
[Prev in Thread] | Current Thread | [Next in Thread] |