diff options
author | Jim Blandy <jimb@red-bean.com> | 1997-04-19 13:04:38 +0000 |
---|---|---|
committer | Jim Blandy <jimb@red-bean.com> | 1997-04-19 13:04:38 +0000 |
commit | ef00e7f4668965ccc3ec6a56b02dedc04a1b8f51 (patch) | |
tree | a8133b7e80975eeb7bbc69ec3c0a4b65e28cd94e | |
parent | f17e0404972cbb0ab0664cfe1aa3ec2a4d2b4107 (diff) | |
download | guile-ef00e7f4668965ccc3ec6a56b02dedc04a1b8f51.tar.gz |
* boot-9.scm (eval-string, command-line, load-user-init): New
functions.
-rw-r--r-- | ice-9/boot-9.scm | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/ice-9/boot-9.scm b/ice-9/boot-9.scm index 414b1e0d8..919b5d7ae 100644 --- a/ice-9/boot-9.scm +++ b/ice-9/boot-9.scm @@ -775,6 +775,36 @@ file))) +;;; {Help for scm_shell} +;;; The argument-processing code used by Guile-based shells generates +;;; Scheme code based on the argument list. This page contains help +;;; functions for the code it generates. + +(define (eval-string string) + (call-with-input-string + string + (lambda (port) + (let loop () + (let ((expr (read port))) + (if (eof-object? expr) #f + (begin (eval expr) (loop)))))))) + +(define (command-line) (program-arguments)) + +(define (load-user-init) + (define (has-init? dir) + (let ((path (in-vicinity dir ".guile"))) + (catch 'system-error + (lambda () + (let ((stats (stat path))) + (if (not (eq? (stat:type stats) 'directory)) + path))) + (lambda dummy #f)))) + (let ((path (or (has-init? (getenv "HOME")) + (has-init? (passwd:dir (getpw (getuid))))))) + (if path (primitive-load path)))) + + ;;; {Loading by paths} ;;; Load a Scheme source file named NAME, searching for it in the |