Sourcing a script can be useful for exporting variables in the current shell.
However, you can’t use “dirname $0″ to get the directory of the script.
Here’s how to get the same effect of dirname, but still allowing you to export variables.
Relative path:
DIRNAME=${BASH_ARGV[0]%/*}
Full path:
ABSDIR=$PWD/${BASH_ARGV[0]%/*}