title: Program hanging after its execution--not finishing
body: <p>Currently have a shell program that is supposed to gather some general system information for Admin purposes. </p>
  
  <p>ISSUE: after the execution of the program, it seems to hang and never complete. After doing some tinkering I noticed that it appear to be hanging after the call to the "DumpInfo" method </p>
  
  <pre><code># 
  # Description: 
  # Gather general system info then place info in dumpfile
  # 
  # Usage: 
  # bash getlocal.sh &lt; cmds.txt, cmds.txt is a file with a list of commands to run
  #
  #
  
  function SepCmds() 
  { 
          LCMD=${ALINE%%|*} 
          REST=${ALINE#*|} 
          WCMD=${REST%%|*} 
          REST=${REST#*|}  
          TAG=${REST%%|*} 
  
          if [[ $OSTYPE == "MSWin" ]] 
          then 
                  CMD="$WCMD" 
          else 
                  CMD="$LCMD"
          fi
  }
  
  function DumpInfo ()
  { 
          printf '&lt;systeminfo host="%s" type="%s"' "$HOSTNAME" "$OSTYPE"
          printf ' date="%s" time="%s"&gt;\n' "$(date '+%F')" "$(date '+%T')"
          readarray CMDS
          for ALINE in "${CMDS[@]}" 
          do 
                  #ignore comments 
                  if [[ ${ALINE:0:1} == '#' ]] ; then continue ; fi 
  
                  SepCmds
  
                  if [[ ${CMD:0:3} == N/A ]] 
                  then 
                          continue
                  else 
                          printf "&lt;%s&gt;\n" $TAG
                          $CMD
                          printf "&lt;/%s&gt;\n" $TAG
                  fi
          done 
          printf "&lt;/systeminfo&gt;\n"
  }
  
  OSTYPE=$(./osdetect.sh) 
  HOSTNM=$(hostname) 
  TMPFILE="${HOSTNM}.info"
  
  # gather the info into the tmp file; errors as well 
  DumpInfo &gt; $TMPFILE 2&gt;&amp;1
  </code></pre>