How to change the current SBCL directory?

It is very easy to change the current CLisp working directory:

>cat ~/.clisprc.lisp ;;; The following lines added by ql:add-to-init-file: #-quicklisp (let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp" (user-homedir-pathname)))) (when (probe-file quicklisp-init) (load quicklisp-init))) (cd "/media/E/www/qachina/db/doc/money") (load "money") 

However, it looks like there is no similar cd function in SBCL. How can this be done using SBCL?

+6
source share
5 answers
 CL-USER> (sb-posix:chdir "/home/apugachev") 0 CL-USER> (sb-posix:getcwd) "/home/apugachev" CL-USER> (sb-posix:chdir "/tmp/") 0 CL-USER> (sb-posix:getcwd) "/tmp" 
+11
source
 (setf *default-pathname-defaults* #P"/New/Absolute/Path/") 
+5
source

There was the same question. Off

 (setf *default-pathname-defaults* (truename "./subdir")) 

changes the boot path to subdir. If you do not need a relative path, then

 (setf *default-pathname-defaults* (truename "/absolute/path")) 
+3
source

It’s better to answer right now: use (uiop:chdir "some/path") .

Or you can use this function to temporarily change the directory:

(uiop:call-with-current-directory "some/path" (lambda () (do-the-job))

Or this macro for a more convenient way:

(uiop:with-current-directory ("some/path") (do-the-job))

+2
source

Now I use rlwrap to run SBCL and solves this problem

 $"cat ~/bin/sb" breakchars="(){}[],^%$#@\"\";:''|\\" cd /media/E/www/qachina/db/doc/money/ exec rlwrap --remember -c -b "$breakchars" -f "$HOME"/.sbcl_completions sbcl " $@ " 

then run sb .

+1
source

Source: https://habr.com/ru/post/899100/


All Articles