I have a script that I call via . ./env/setenv.sh. In this script, I'm calling a python script that's also located in ./env/.
My current directory is along the lines of ~/dev/project/ and I'm calling into ~/dev/project/env via . ./env/setenv.sh
My attempts (${dirname $0}) to reference the location of setenv.sh from within itself hasn't been successful, because my current working directory is considered /bin rather than ~/dev/project/env/ (I assume due to me sourcing it with .)
What other options do I have for referencing the current working directory of the setenv.sh script, so that it can call my .py script from within the same directory?
e.g.,
WORKING_DIR=$(dirname "$0")
echo $WORKING_DIR
export VAR=$(python $WORKING_DIR/script.py)"
When called via . ./env/setenv.sh prints: /bin, and can't locate script.py