Unify initialization of scsh-specific stuff.

This commit is contained in:
mainzelm 2002-05-16 14:34:58 +00:00
parent 021cd1efc1
commit dcebc64e8b
3 changed files with 42 additions and 55 deletions

View File

@ -295,6 +295,7 @@
(files startup)) (files startup))
(define-structure scsh-top-package (export parse-switches-and-execute (define-structure scsh-top-package (export parse-switches-and-execute
with-scsh-initialized
repl ) repl )
(open command-processor (open command-processor
command-levels ; with-new-session command-levels ; with-new-session

View File

@ -45,27 +45,12 @@
(define (dump-scsh-program start filename) (define (dump-scsh-program start filename)
(let ((context (user-context))) (let ((context (user-context)))
(really-dump-scsh-program (lambda (args) (really-dump-scsh-program (lambda (args)
(with-scsh-sighandlers (with-scsh-initialized
#f #f context args
(lambda () (lambda ()
(with-autoreaping (start args))))
(lambda ()
(install-env)
(initialize-cwd)
(init-scsh-vars #f) ; Do it quietly.
(start-new-session context
(current-input-port)
(current-output-port)
(current-error-port)
args
#f)
(with-interaction-environment
(user-environment)
(lambda ()
(start args))))))))
filename))) filename)))
(define (scsh-stand-alone-resumer start) (define (scsh-stand-alone-resumer start)
(usual-resumer ; sets up exceptions, interrupts, (usual-resumer ; sets up exceptions, interrupts,
; and current input & output ; and current input & output

View File

@ -297,40 +297,41 @@
(get-reflective-tower (user-environment)) ; ??? (get-reflective-tower (user-environment)) ; ???
name)) name))
(define (parse-switches-and-execute all-args context) (define (with-scsh-initialized interactive? context args thunk)
(receive (switches term-switch term-val top-entry args)
(parse-scsh-args (cdr all-args))
(begin
;;; restart-command-processor will provide one, but we need
;;; one already in do-switches
(start-new-session context
(current-input-port)
(current-output-port)
(current-error-port)
args
term-switch)
(with-interaction-environment
(user-environment)
(lambda ()
(with-scsh-sighandlers (with-scsh-sighandlers
(not term-switch) interactive?
(lambda () (lambda ()
(with-autoreaping (with-autoreaping
(lambda () (lambda ()
(install-env) (install-env)
(initialize-cwd) (initialize-cwd)
(init-scsh-vars interactive?)
(start-new-session context
(current-input-port)
(current-output-port)
(current-error-port)
args
(not interactive?))
(with-interaction-environment
(user-environment)
thunk))))))
(define (parse-switches-and-execute all-args context)
(receive (switches term-switch term-val top-entry args)
(parse-scsh-args (cdr all-args))
(begin
(with-scsh-initialized
(not term-switch) context args
(lambda ()
;; Have to do these before calling DO-SWITCHES, because actions ;; Have to do these before calling DO-SWITCHES, because actions
;; performed while processing the switches may use these guys. ;; performed while processing the switches may use these guys.
(set-command-line-args! (set-command-line-args!
(cons (if (eq? term-switch 's) (cons (if (eq? term-switch 's)
(if (string? term-val) (if (string? term-val)
term-val ; Script file. term-val ; Script file.
"file-descriptor-script"); -sfd <num> "file-descriptor-script") ; -sfd <num>
(car all-args)) (car all-args))
args)) args))
;; Set HOME-DIRECTORY and EXEC-PATH-LIST,
;; quietly if not running an interactive script.
(init-scsh-vars term-switch)
(let* ((script-loaded? (do-switches switches term-val))) (let* ((script-loaded? (do-switches switches term-val)))
(if (and (not script-loaded?) ; There wasn't a -ds or -dm, (if (and (not script-loaded?) ; There wasn't a -ds or -dm,
@ -370,7 +371,7 @@
;; Otherwise, the script executed as it loaded, ;; Otherwise, the script executed as it loaded,
;; so we're done. ;; so we're done.
(else (call-exit-hooks) (else (call-exit-hooks)
(scheme-exit-now 0))))))))))))) (scheme-exit-now 0)))))))))
(define (read-exactly-one-sexp-from-string s) (define (read-exactly-one-sexp-from-string s)