In my .bash_profile file, I have this, which works fine to execute that script in the same process that I'm launching my shell...
. ~/Code/iOS/CommunityDemo/APIMocker/mockutil.sh
I realized for part of that script, I need the path where it resides to be used within it. Normally, you'd just do this...
MOCKUTIL_PATH=$(dirname "$0")
However, since I'm not spawning the script into its own process, but rather including the script in my profile script, the above understandably yields /bin, not ~/Code/iOS/CommunityDemo/APIMocker as I need.
"No worries!" I figured... I'd just export the path from within my profile, like this...
export MOCKUTIL_PATH="~/Code/iOS/CommunityDemo/APIMocker"
. ${MOCKUTIL_PATH}/mockutil.sh
but I'm getting this...
bash: ~/Code/iOS/CommunityDemo/APIMocker/mockutil.sh: No such file or directory
Now I can just do this, but I really hate redundancy!
export MOCKUTIL_PATH="~/Code/iOS/CommunityDemo/APIMocker"
. ~/Code/iOS/CommunityDemo/APIMocker/mockutil.sh
So... is there a way to define that path once, then use that definition in the source (.) command?