Closed dieggsy closed 7 years ago
Actually they should not; when scripts get called in, *default-pathname-defaults*
should be bound to the caller's cwd. This should be enough for anything inside the lisp, using merge-pathnames
, but you may want to pass it on to things like run-program
, where it's unfortunate *default-pathname-defaults*
isn't the default.
@rpav Ah, I see. when using
(defun my-ls ()
(dolist (file (directory "*.*"))
(write-line (namestring file))))
instead, it works as expected. Thanks! So there's no way around this with run-program?
Also, what about making scripts in a different directory than *default-pathname-defaults*
?
If you mean SBCL's run-program
, just pass it :directory *default-pathname-defaults*
. Others are likely similar.
For make-script
, try locally binding it, e.g.,
(let ((*default-pathname-defaults* #P"/path/to/script"))
(make-script ...)
I'm actually not 100% sure this works, and if it doesn't it's a legit bug. There should be (and it would be trivial to write) something like with-path
so you could just do:
(with-path (#P"...")
...)
This would save typing out long ugly variable names if you do this a lot.
Great, all of this seems to work. Thanks!
EDIT: (Briefly did something sorta dumb, but it's sorted out now).
Try with bef41db, apparently it wasn't doing merge-pathnames
on the actual target usage.
I was wondering:
Is there a way to create scripts elsewhere/at a specified directory (from inside lisp) ? (Some option to make-script I missed or something like that?)
Is there a way for scripts to have a notion of where they're being run? For a kinda dumb example, if I wrote:
Any calls to the ls script would only list the files where the script itself resides, not for the directory where the script is being called from.