Hello,
The following patch to module/ice-9/boot-9.scm adds an optional
GUILE_USER_INIT environment variable that allows users to specify an
alternative location for their init file. When the variable is unset
or the specified file doesn't exist, it falls back to the existing
'~/.guile' behavior automatically.
I also updated doc/guile.1 to reflect the addition.
Since this touches documentation, I've requested copyright assignment
forms as a precaution.
Thanks.
---
diff --git a/doc/guile.1 b/doc/guile.1
index 77c8639..2c2e3d6 100644
--- a/doc/guile.1
+++ b/doc/guile.1
@@ -212,6 +212,16 @@ Scheme files (.go files) when loading.
It should be a colon-separated list of directories,
which will be prefixed to the default
.B %load-compiled-path.
+.TP
+.B GUILE_USER_INIT
+If
+.RB $ GUILE_USER_INIT
+is set before
+.B guile
+is started and points to a file,
+its contents are executed before any other processing occurs.
+If not net, the default is
+.I ~/.guile
.
.SH FILES
.TP
diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index aaa9987..3ff3377 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -2200,12 +2200,16 @@ not already present. This helps create file
names."
;; scm_compile_shell_switches.
(define (load-user-init)
- (let* ((home (or (getenv "HOME")
- (false-if-exception (passwd:dir (getpwuid
(getuid))))
- file-name-separator-string)) ;; fallback for cygwin
etc.
- (init-file (in-vicinity home ".guile")))
- (if (file-exists? init-file)
- (primitive-load init-file))))
+ (let ((user-init-path (getenv "GUILE_USER_INIT")))
+ (if (and user-init-path (file-exists? user-init-path))
+ (begin (primitive-load user-init-path))
+ (begin
+ (let* ((home (or (getenv "HOME")
+ (false-if-exception (passwd:dir (getpwuid
(getuid))))
+ file-name-separator-string)) ;; fallback for
cygwin etc.
+ (init-file (in-vicinity home ".guile")))
+ (if (file-exists? init-file)
+ (primitive-load init-file)))))))