title: Bash script triggered remotely via ssh not working properly
body: <p>I have a script on a remote machine which contains a for loop as below:</p>
  <pre class="lang-sh prettyprint-override"><code>#!/bin/bash -eux
  
  # execute build.sh in each component
  for f in workspace/**/**/build.sh ; do
    echo $f
    REPO=${f%*build.sh}
    echo $REPO
    git -C ./$REPO checkout master
    git -C ./$REPO pull origin master
    $f
  done
  </code></pre>
  <p>This script is finding all the repos with a <code>build.sh</code> file inside, pulls the latest changes and build them.</p>
  <p>This works fine when I execute the scrript on the machine but when I try to trigger this script remotely the for loop just runs once, and I see that it returns a repo which actually doesn't have <code>build.sh</code> at all:</p>
  <pre><code>$ ssh devops &quot;~/build.sh&quot;
  + for f in workspace/**/**/build.sh
  + echo 'workspace/**/**/build.sh'
  + REPO='workspace/**/**/'
  + echo workspace/core/auth/
  workspace/**/**/build.sh
  workspace/core/auth/
  + git -C ./workspace/core/auth/ checkout master
  Already on 'master'
  Your branch is up to date with 'origin/master'.
  + git -C ./workspace/core/auth/ pull origin master
  From https://gitlabe.com/workspace/core/auth
   * branch            master     -&gt; FETCH_HEAD
  Already up to date.
  + 'workspace/**/**/build.sh'
  /home/devops/build.sh: line 10: workspace/**/**/build.sh: No such file or directory
  </code></pre>
  <p>I tried to make a one-liner of the for loop and use ssh and that also didn't work. How can I solve this problem?</p>