Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the path of the script that is currently executing in Steel Bank Common Lisp

I'm calling a CL script from various places in the system. How do I get the file path of the script that is currently executed?

For example, the script source file is located in the /home/user/project/source/ directory. The script is being executed from the /home/user/ directory in the following manner:

user@machine:~$ ./project/source/script.lsp

Regardless of the callers location, script should know that it's located in the /home/user/project/source/ directory.

I've tried using the *default-pathname-defaults* variable, but the following command shows the directory from which the script was called:

(format t "Pathname: ~S~&" *default-pathname-defaults*)

Environment: SBCL 1.4.5.debian on Ubuntu 18.04.

like image 838
Vjekoart Avatar asked Dec 09 '25 01:12

Vjekoart


1 Answers

The *load-truename* and *compile-file-truename* variables are bound to the truename of the file being loaded with cl:load or compiled with cl:compile-file at the time of loading or compilation, respectively.

In your case, *load-truename* is the thing to use. It will give a full, absolute pathname to the script.

like image 89
Xach Avatar answered Dec 11 '25 15:12

Xach



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!