test2.sh:
#!/bin/bash
MY_VARIABLE=$(PWD)/$(dirname $BASH_SOURCE)
echo MY_VARIABLE is : $MY_VARIABLE
Ligue:
./test2.sh
Saída:
MY_VARIABLE is : /some/path/.
Ligue:
source ./test2.sh
Saída:
MY_VARIABLE is : /some/path/.
Obrigado @webmark e @GordonDavisson.