title: how to access an automatically named variable in a Bash shell script
body: <p>I have some code that creates a variable of some name automatically and assigns some value to it. The code is something like the following:</p>
  
  <pre><code>myVariableName="zappo"
  eval "${myVariableName}=zappo_value"
  </code></pre>
  
  <p>How would I access the value of this variable using the automatically generated name of the variable? So, I'm looking for some code a bit like the following (but working):</p>
  
  <pre><code>eval "echo ${${myVariableName}}"
  </code></pre>
  
  <p>(... which may be used in something such as myVariableValue="$(eval "echo ${${myVariableName}}")"...).</p>
  
  <p>Thanks muchly for any assistance</p>
  
  <p>If you think this approach is madness and want offer more general advice, the general idea I'm working on is having variables defined in functions in a library with such names as ${usage} and ${prerequisiteFunctions}. These variables that are defined within functions would be accessed by an interrogation function that can, for instance, ensure that prerequisites etc. are installed. So a loop within this interrogation function is something like this:</p>
  
  <pre><code>for currentFunction in ${functionList}; do
      echo "function: ${currentFunction}"
      ${currentFunction} -interrogate # (This puts the function variables into memory.)
      currentInterrogationVariables="${interrogationVariables}" # The variable interrogationVariables contains a list of all function variables available for interrogation.
      for currentInterrogationVariable in ${currentInterrogationVariables}; do
          echo "content of ${currentInterrogationVariable}:"
          eval "echo ${${currentInterrogationVariable}}"
      done
  done
  </code></pre>
  
  <p>Thanks again for any ideas!</p>