I'm trying to define in a q script a dir relative to the path of the script itself.
I tried to do this:
dir:system "realpath ../hdb"
However this works only if I launch the script from the path where it resides. i.e. \pwd returns the path of the directory where the script is launched from, not the path of the script itself.
My goal is to be able to run the script from anywhere and the variable dir will always point to ../hdb relative to the path of the script.
In bash it is possible to change the current working directory to that of the where the script is, using cd `dirname $0` where $0 is the script name.
Is it possible to do this in q or am I going about this the wrong way.
The reason I want to do this is so that I don't have to explicitly define the absolute path, since deploying code under different users for example means I must manually change the path each time. (Not just the user ... I want to be able to deploy anywhere and it'll just run).
I could use a bash script that changes the directory for me but can I do it in q?