title: Associative arrays are local by default
body: <p>Associative arrays seem to be local by default when declared inside a function body, where they should be global. The following code</p>
  
  <pre><code>#!/bin/bash
  
  f() {
      declare -A map
      map[x]=a
      map[y]=b
  }
  
  f
  echo x: ${map[x]} y: ${map[y]}
  </code></pre>
  
  <p>produces the output:</p>
  
  <pre><code>x:  y:
  </code></pre>
  
  <p>while this</p>
  
  <pre><code>#!/bin/bash
  
  declare -A map
  
  f() {
      map[x]=a
      map[y]=b
  }
  
  f
  echo x: ${map[x]} y: ${map[y]}
  </code></pre>
  
  <p>produces the output:</p>
  
  <pre><code>x: a y: b
  </code></pre>
  
  <hr>
  
  <p>Is it possible to declare a global associative array within a function?
  Or what work-around can be used?</p>