title: Cannot make bash script work from cloud-init
body: <p>Obviously I am doing something wrong here.</p>
  
  <p>Cloud init script <code>/etc/cloud/cloud.cfg</code></p>
  
  <pre><code>...
  runcmd:
   - [ sh, /opt/cloud-init-scripts/whatever.sh ]
  </code></pre>
  
  <p>The script <code>/opt/cloud-init-scripts/whatever.sh</code></p>
  
  <pre><code>#!/bin/bash
  ...
  . /home/ubuntu/third-party/script.sh --silent
  </code></pre>
  
  <p>Third party script <code>/home/ubuntu/third-party/script.sh</code></p>
  
  <pre><code>#!/usr/bin/env bash
  
  function some_function() {
  ...
  </code></pre>
  
  <p>Error I am getting in <code>/var/log/cloud-init-output.log</code></p>
  
  <pre><code>/opt/cloud-init-scripts/whatever.sh: 3: /home/ubuntu/third-party/script.sh: Syntax error: "(" unexpected
  </code></pre>
  
  <p>I must be missing something obvious here. I tried using <code>source</code>, <code>.</code> and <code>sh</code> when calling the third party script, tried changing shebangs everywhere but no success.</p>
  
  <p>If I run the same command from command line it works.</p>