In a script which I call with the "source" command under linux I want to determine the directory where the script is located. Assuming there is a script under $HOME/foo/bar/sourceme and i call the script from $HOME with source $HOME/foo/bar/sourceme I would like to extract within the script that it is located under $HOME/foo/bar. I know that it is possible without source by using
set _dir = `dirname $0`
setenv MY_DIR = `cd $_dir ; pwd`
but this doesn't work when i use a source.