Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.unix.shell > #4906

Re: bash: Initialisation of an associative array using a compound assignment

From "Chris F.A. Johnson" <cfajohnson@gmail.com>
Newsgroups comp.unix.shell
Subject Re: bash: Initialisation of an associative array using a compound assignment
Date 2012-05-04 14:24 -0400
Organization A noiseless patient Spider
Message-ID <3gjd79-lha.ln1@cjlocal.com> (permalink)
References <0d56e766-9a3f-45ec-a8e9-b212375cf035@gn8g2000vbb.googlegroups.com>

Show all headers | View raw


On 2012-05-04, Francis Moreau wrote:
> Hello,
>
> I don't understand why initialising an associative array like the
> following doesn't work:
>
>   $ declare -A a
>   $ a=($(echo '[key]=val')
>   bash: a: [key]=val: must use subscript when assigning associative
> array
>
> Could anybody enlight me ?

a=( [key]=val )

  Or:

eval "a=( $(echo '[key]=val') )"


-- 
   Chris F.A. Johnson, author           <http://shell.cfajohnson.com/>
   ===================================================================
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)

Back to comp.unix.shell | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

bash: Initialisation of an associative array using a compound assignment Francis Moreau <francis.moro@gmail.com> - 2012-05-04 01:43 -0700
  Re: bash: Initialisation of an associative array using a compound assignment "Chris F.A. Johnson" <cfajohnson@gmail.com> - 2012-05-04 14:24 -0400
    Re: bash: Initialisation of an associative array using a compound assignment Barry Margolin <barmar@alum.mit.edu> - 2012-05-04 19:15 -0400
      Re: bash: Initialisation of an associative array using a compound assignment Janis Papanagnou <janis_papanagnou@hotmail.com> - 2012-05-05 09:42 +0200
        Re: bash: Initialisation of an associative array using a compound assignment Barry Margolin <barmar@alum.mit.edu> - 2012-05-05 17:43 -0400
          Re: bash: Initialisation of an associative array using a compound assignment Janis Papanagnou <janis_papanagnou@hotmail.com> - 2012-05-06 03:41 +0200
            Re: bash: Initialisation of an associative array using a compound assignment Barry Margolin <barmar@alum.mit.edu> - 2012-05-05 22:34 -0400
        Re: bash: Initialisation of an associative array using a compound assignment Francis Moreau <francis.moro@gmail.com> - 2012-05-06 07:30 -0700
      Re: bash: Initialisation of an associative array using a compound assignment Francis Moreau <francis.moro@gmail.com> - 2012-05-06 07:35 -0700
      Re: bash: Initialisation of an associative array using a compound assignment Francis Moreau <francis.moro@gmail.com> - 2012-05-08 00:57 -0700
  Re: bash: Initialisation of an associative array using a compound assignment Stephane Chazelas <stephane.chazelas@gmail.com> - 2012-05-06 17:16 +0100
    Re: bash: Initialisation of an associative array using a compound assignment Janis Papanagnou <janis_papanagnou@hotmail.com> - 2012-05-07 02:06 +0200

csiph-web