title: "bash: Array and Bad substitution" when using do in .sh file
body: <p>I wuld like to create a script who run some program and check if they started or no, unfortunately I receive several error and I don't know why:</p>
  
  <pre><code>#!/bin/sh
  # start file
  
  c[0] = 'foo'
  c[1] = 'mickey'
  c[2] = 'mouse'
  
  echo "Launching..."
  
  for i in 0 1 2; do
          echo "Starting ${c[i]}"
          ${c[i]}
          ps cax | grep ${c[i]}
          if [ $? -eq 0 ]; then
            echo "${c[i]} is running"
          else
          {
              echo "${c[i]} is not running"
              ${c[i]}
          } 
          fi
  done
  
  echo "launch completed."
  </code></pre>
  
  <p>when I try to run it, the shell don't recognize both the command name and I receive error also on the line</p>
  
  <pre><code>for i in 0 1 2; do
  </code></pre>
  
  <p>for "Bad substitution".</p>
  
  <p>Can you please explain where I'm wrong with this script? Thanks in advance.</p>
  
  <p>---- Update ---- </p>
  
  <p>Thanks to us for your REALLY PRECIOUS answers, I modified my script according to your advices:</p>
  
  <pre><code>#!/bin/bash
  # start file
  
  
  echo "Launching..."
  
  for i in foo mickey mouse; do
          echo "Starting $i"
          $i
          ps cax | grep $i
          if [ $? -eq 0 ]; then
            echo "$i is running"
          else
              echo "$i is not running"
              $i
          fi
  done
  
  echo "launch completed."
  </code></pre>
  
  <p>Thanks again!
  Fabrizio</p>