title: Double Clicking a shell script on Mac
body: <p>i have a small script that runs a jar file : </p>
  
  <pre><code>#!/bin/bash
  
  prefix="foo";
  name=`ls ${prefix}*.jar`;
  echo $name;
  java -jar $name prop1.properties prop2.properties
  </code></pre>
  
  <p>when i run it in the terminal using ./myscript.sh, it works fine and the jar file executes, but when i rename it in myscript.command and double click it, i have this error :</p>
  
  <pre><code>ls: foo*.jar : No such file or directory
  </code></pre>
  
  <p>I saw that apparently a .command file opens a terminal at the root directory, so I tried finding the directory containing myscript.command using that :</p>
  
  <pre><code>dir = 'find &lt;dir&gt; -maxdepth 1 -type d -name '*myDirContainingJar*' -print -quit'
  cd $dir
  </code></pre>
  
  <p>but dir is just blank, any ideas ???</p>