I have a small app I'm building and when I hand it off to other team members to work on I'd like to abstract out them having to execute the python script with args directly, and instead have them call on a shell script to do it automatically. Repo structure below:
src/
app.py
module_name.py
scripts/
runAppWithArgs.sh
In runAppWithArgs.sh
, I thought to cd ../src
and then execute my python code, however I found that if I called on the script as ./scripts/runAppWithArgs.sh
(i.e from the top-level directory) since the 'working directory' isn't scripts/
, I'm getting errors because it doesn't know how to cd
into src/
correctly.
What is the fix for this? At a high level I would like to "assert" that the shell script is running in the right directory context, and the only workaround i can think of seems kind of hacky where I try to parse out the working directory from pwd
and then move to the correct directory as-needed, although I think that will require some hard coding that I'm not comfortable doing.
Any pointers would be appreciated!