Make (cd "/nonexistent") fail.
authorTaylor R Campbell <campbell@mumble.net>
Sun, 6 Apr 2014 22:08:53 +0000 (22:08 +0000)
committerTaylor R Campbell <campbell@mumble.net>
Sun, 6 Apr 2014 22:08:54 +0000 (22:08 +0000)
Kinda kludgey, but it'll do for interactive use.

See XXX comment for what a proper solution should look like.

src/runtime/wrkdir.scm

index 5cfa2bbdb113b1d1a47d571ae619a3f9cd0806e5..35c437521abdc4f9622d04be03ed8354694ebcf3 100644 (file)
@@ -49,6 +49,20 @@ USA.
 
 (define (set-working-directory-pathname! name)
   (let ((pathname (new-pathname name)))
+    ;; XXX Checking FILE-DIRECTORY? is a stop-gap kludge until we fix
+    ;; the concept of `working directory' by (a) making it be the
+    ;; directory, not the pathname; (b) making it thread-local, and (c)
+    ;; opening it in SET-WORKING-DIRECTORY! and hanging onto it for
+    ;; relative lookups, either by changing directory just before each
+    ;; lookup or using relative lookup system calls.
+    (if (not (file-directory? pathname))
+       (error:file-operation name "enter" "directory"
+                             (if (file-exists?
+                                  (directory-pathname-as-file pathname))
+                                 "not a directory"
+                                 "no such directory")
+                             'SET-WORKING-DIRECTORY-PATHNAME!
+                             (list name)))
     (set! *working-directory-pathname* pathname)
     (set! *default-pathname-defaults* pathname)
     (cmdl/set-default-directory (nearest-cmdl) pathname)