title: variable undefined after nested for loop
body: <p>I'm trying to create a script that allows a user to choose backup destinations from the mounted volumes.</p>
  <p>While I had a first draft working it had repetition which I've tried to remove by rebuilding in a nested for loop, however by the end of the script my variables become undefined and i can't see what mistake I've made.</p>
  <p>why are my variables defined at line 19 but not at lines 27-29?</p>
  <p>I am a beginner, apologies if the answer is obvious.</p>
  <pre><code>#!/bin/bash
  
  VOLUMES=$(ls /volumes)
  
  WORKING_DRIVE=
  MASTER_DRIVE=
  CLONE_DRIVE=
  
  echo
  for BACKUP_DESTINATION in 'Working Drive' 'Master Drive' 'Clone Drive'
  do
      for VOLUME_VARIABLE in &quot;${WORKING_DRIVE}&quot; &quot;${MASTER_DRIVE}&quot; &quot;${CLONE_DRIVE}&quot;
      do
          echo &quot;Select your ${BACKUP_DESTINATION}&quot;
          echo
          select VOLUME_VARIABLE in $VOLUMES
          do
              echo
              echo &quot;${BACKUP_DESTINATION}: $VOLUME_VARIABLE&quot;
              echo
              break
          done
          break
      done
  done
  
  echo &quot;Working Drive is: ${WORKING_DRIVE}&quot;
  echo &quot;Master Drive is: ${MASTER_DRIVE}&quot;
  echo &quot;Clone Drive is: ${CLONE_DRIVE}&quot;
  </code></pre>