title: Shell Scripts in Mac OS X run from home directory?
body: <p>I'm a longtime Windows and Linux user and have had some weird experiences writing shell scripts on Mac OS X.  In particular, I can write the scripts just fine and run them from the terminal, but every time I try running one from a Finder window it always executes from the user's home directory rather than the directory in which the script lives.  That is, if the script is located at</p>
  
  <pre><code>~/path/to/the/script.sh
  </code></pre>
  
  <p>it always runs out of <code>~</code>.  In the past I've had to ask my more Mac-savvy friends how to fix this, and they've often done so using some perversely awful techniques, but I don't see any reason why this should be the case.</p>
  
  <p>My question is - is there an easy way to write a shell script in Mac OS X that, when double-clicked in Finder, runs out of the directory in which it resides?</p>