I am using a shared SLURM cluster. I am trying to get the path of the bash script from inside the script itself.
There is already an excellent thread here: https://stackoverflow.com/questions/59895/get-the-source-directory-of-a-bash-script-from-within-the-script-itself. Unfortunately, none of those solutions work for me. They work when I execute the bash script normally, but not when I submit the script as a job. I tried $BASH_SOURCE, $0, $_, and readlink /proc/$$/fd/255. They all return something like /cm/local/apps/slurm/var/spool/jobXXXXXX/slurm_script, which is a path auto-generated by SLURM and has nothing to do with the script I submitted. I doubt there are any other solutions that directly answer my question that are not already mentioned, but is there maybe some way to override whatever the cluster is doing? Can I somehow restore standard bash behavior?