On Thu, 28 Feb 2008, Florin Iucha wrote:

> Now, can a kind soul wait a couple more days to see if the horse is well 
> done or still twitching, then write up a concise and correct reply 
> (preferably to the original message) so it is archived for posterity?

Maybe we should continue to include the latest and greatest in every 
reply:

#!/bin/bash --
EXEC_DIR=$(builtin cd -P -- "${0%/*}" && builtin pwd)
echo "$EXEC_DIR"


I think this thread will be a great learning experience for someone who 
wants to understand what the issues are.  There is a lot in these 
messages.  It's nice to have an answer to the original question, but how 
that answer was arrived at is also important.

If you search the web for the answer, you will find lots of answers, many 
of which don't work at all.  Other suggested answers will fail under 
common conditions.  Some are just not optimal.

Regarding the above script, is the "--" needed after "bash"?  I don't 
think it is because there is nothing else on that line.

Mike