title: Bash - error message 'Syntax error: "(" unexpected'
body: <p>For some reason, this function is working properly. The terminal is outputting</p>
  <blockquote>
  <p>newbootstrap.sh: 2: Syntax error: &quot;(&quot; unexpected</p>
  </blockquote>
  <p>Here is my code (line 2 is function <code>MoveToTarget() {</code>)</p>
  <pre><code>#!/bin/bash
  function MoveToTarget() {
      # This takes two arguments: source and target
      cp -r -f &quot;$1&quot; &quot;$2&quot;
      rm -r -f &quot;$1&quot;
  }
  
  function WaitForProcessToEnd() {
      # This takes one argument. The PID to wait for
      # Unlike the AutoIt version, this sleeps for one second
      while [ $(kill -0 &quot;$1&quot;) ]; do
          sleep 1
      done
  }
  
  function RunApplication() {
      # This takes one application, the path to the thing to execute
      exec &quot;$1&quot;
  }
  
  # Our main code block
  pid=&quot;$1&quot;
  SourcePath=&quot;$2&quot;
  DestPath=&quot;$3&quot;
  ToExecute=&quot;$4&quot;
  WaitForProcessToEnd $pid
  MoveToTarget $SourcePath, $DestPath
  RunApplication $ToExecute
  exit
  </code></pre>