Set up __SCRIPT_PATH__ and __SCRIPT_DIR__ variables in CommandSession.runFromFile
To make it possible to write SCL scripts that take into account the disk location of the executed script, include code in runFromFile
implementation that sets __SCRIPT_PATH__
and __SCRIPT_DIR__
variables of type Maybe Path
for the script to use to evaluate file system paths relative to the script's location.
The rationale for having the type Maybe Path
is that it is possible that the java.nio.file
API can under some circumstances fail to resolve the provided String filename into a Path, the evaluation of the script should still be possible as long as the file can be read, even without the location information.
Edited by Tuukka Lehtonen