I'd like to use Nashorn for shell scripting, however I can't find the analog of the Bash variable $0
which tells me the path of the running script so that I could launch other scripts that are in the same folder (this is different from the working directory).
The __DIR__
and __FILE__
values available in Nashorn JavaScript will help you implementing a substitute for $0
. The former gives you the current file's directory; the latter, the file name.