2000-05-14 Gary Houston <ghouston@arglist.com>
authorGary Houston <ghouston@arglist.com>
Sun, 14 May 2000 22:15:13 +0000 (22:15 +0000)
committerGary Houston <ghouston@arglist.com>
Sun, 14 May 2000 22:15:13 +0000 (22:15 +0000)
* boot-9.scm (load-user-init): rewritten.  first work out the home
directory and then try to open the file (previously it could try
to open a file in more than one place).  catch exceptions when
trying to get a directory from the user database.  don't check
that ~/.guile is not a directory before trying to load it (a lack
of ~/.guile is not a crime, but if the file is not valid for any
reason then primitive-load will raise an error).

ice-9/boot-9.scm

index 034e1a8..1157c7b 100644 (file)
 ;; This is mostly for the internal use of the code generated by
 ;; scm_compile_shell_switches.
 (define (load-user-init)
-  (define (existing-file dir)
-    (let ((path (in-vicinity dir ".guile")))
-      (if (and (file-exists? path)
-              (not (file-is-directory? path)))
-         path
-         #f)))
-  (let ((path (or (existing-file (or (getenv "HOME") "/"))
-                  (and (provided? 'posix) 
-                      (existing-file (passwd:dir (getpw (getuid))))))))
-    (if path (primitive-load path))))
+  (let* ((home (or (getenv "HOME")
+                  (false-if-exception (passwd:dir (getpwuid (getuid))))
+                  "/"))  ;; fallback for cygwin etc.
+        (init-file (in-vicinity home ".guile")))
+    (if (file-exists? init-file)
+       (primitive-load init-file))))
 
 \f
 ;;; {Loading by paths}