Add switches to evaluate exec scripts.

This commit is contained in:
mainzelm 2003-01-27 20:08:43 +00:00
parent a5e76d4484
commit b9eb4c055c
1 changed files with 23 additions and 7 deletions

View File

@ -54,6 +54,7 @@
;;;
;;; -l <file> Load <file> into current package.
;;; -lm <file> Load <file> into config package.
;;; -le <file> Load <file> into exec package.
;;; -ll <file> As in -lm, but search the library path list.
;;;
;;; +lp <dir> Add <dir> onto start of library path list.
@ -68,12 +69,13 @@
;;; These two require a terminating -s or -sfd arg:
;;; -ds Load terminating script into current package.
;;; -dm Load terminating script into config package.
;;; -de Load terminating script into exec package.
;;;
;;; -e <entry> Call (<entry>) to start program.
;;;
;;; Terminating switches:
;;; -c <exp> Eval <exp>, then exit.
;;; -s <script> Specify <script> to be loaded by a -ds or -dm.
;;; -s <script> Specify <script> to be loaded by a -ds, -dm, or -de.
;;; -sfd <num> Script is on file descriptor <num>.
;;; -- Interactive scsh.
@ -81,7 +83,7 @@
;;; Return switch list, terminating switch, with arg, top-entry,
;;; and command-line args.
;;; - We first expand out any initial \ <filename> meta-arg.
;;; - A switch-list elt is either "-ds", "-dm", or a (switch . arg) pair
;;; - A switch-list elt is either "-ds", "-dm", "-de", or a (switch . arg) pair
;;; for a -o, -n, -m, -l, or -lm switch.
;;; - Terminating switch is one of {s, c, #f} for -s or -sfd, -c,
;;; and -- respectively.
@ -95,7 +97,7 @@
(let lp ((args (meta-arg-process-arglist args))
(switches '()) ; A list of handler thunks
(top-entry #f) ; -t <entry>
(need-script? #f)) ; Found a -ds or -dm?
(need-script? #f)) ; Found a -ds, -dm, or -de?
; (display args (current-output-port))
(if (pair? args)
(let ((arg (car args))
@ -125,11 +127,12 @@
((string=? arg "--")
(if need-script?
(bad-arg "-ds or -dm switch requires -s <script>")
(bad-arg "-ds, -dm, or -de switch requires -s <script>")
(values (reverse switches) #f #f top-entry args)))
((or (string=? arg "-ds")
(string=? arg "-dm")
(string=? arg "-de")
(string=? arg "+lpsd")
(string=? arg "lpsd+")
(string=? arg "-lp-default")
@ -138,6 +141,7 @@
((or (string=? arg "-l")
(string=? arg "-lm")
(string=? arg "-le")
(string=? arg "-ll")
(string=? arg "lp+")
(string=? arg "+lp")
@ -175,9 +179,9 @@
(define default-lib-dirs '("/usr/local/lib/scsh/modules/"))
;;; Do each -ds, -dm, -o, -n, -m, -l/lm/ll, +lp/+lpe/lp+/lpe+, or
;;; Do each -ds, -dm, -de, -o, -n, -m, -l/lm/ll, +lp/+lpe/lp+/lpe+, or
;;; -lp-clear/lp-default switch, and return the final result package and a
;;; flag saying if the script was loaded by a -ds or -dm.
;;; flag saying if the script was loaded by a -ds, -dm, or -de.
(define (do-switches switches script-file)
;; We don't want to try to parse $SCSH_LIB_DIRS until we actually
@ -208,6 +212,11 @@
; (format #t "loaded module ~s~%" script-file)
(lp switches #t))
((equal? switch "-de")
(load-quietly script-file (user-command-environment))
; (format #t "loaded exec ~s~%" script-file)
(lp switches #t))
((equal? switch "-lp-clear")
(set-mod-dirs! '())
(lp switches script-loaded?))
@ -234,6 +243,11 @@
(load-quietly (cdr switch) (config-package))
(lp switches script-loaded?))
((string=? (car switch) "-le")
; (format #t "loading exec file ~s~%" (cdr switch))
(load-quietly (cdr switch) (user-command-environment))
(lp switches script-loaded?))
((string=? (car switch) "-ll")
(load-library-file (cdr switch) (mod-dirs) script-file)
(lp switches script-loaded?))
@ -344,7 +358,7 @@
args))
(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, -dm, or -de,
(eq? term-switch 's)) ; but there is a script,
(load-quietly term-val ; so load it now.
(interaction-environment)))
@ -486,6 +500,7 @@ switch: -e <entry-point> Specify top-level entry point.
-lm <module-file-name> Load module into config package.
-le <exec-file-name> Load file into exec package.
-l <file-name> Load file into current package.
-ll <module-file-name> As in -lm, but search the library path list.
@ -500,6 +515,7 @@ switch: -e <entry-point> Specify top-level entry point.
-ds Do script.
-dm Do script module.
-de Do script exec.
end-option: -s <script> Specify script.
-sfd <num> Script is on file descriptor <num>.