;;; The scsh argv switch parser. ;;; Copyright (c) 1995 by Olin Shivers. See file COPYING. ;;; Imports: ;;; COMMAND-PROCESSOR: set-batch-mode?! command-loop ;;; ENSURES-LOADED: really-ensure-loaded ;;; ENVIRONMENTS: set-interaction-environment! environment-ref ;;; environment-define! ;;; ERROR-PACKAGE: error ;;; EVALUATION: eval ;;; EXTENDED-PORTS: make-string-input-port ;;; INTERFACES: make-simple-interface ;;; INTERRUPTS: interrupt-before-heap-overflow! ;;; PACKAGE-COMMANDS-INTERNAL: user-environment config-package ;;; get-reflective-tower ;;; PACKAGE-MUTATION: package-open! ;;; PACKAGES: structure-package structure? make-structure ;;; make-simple-package ;;; RECEIVING: mv return stuff ;;; SCSH-LEVEL-0-INTERNALS: set-command-line-args! ;;; SCSH-VERSION: scsh-version-string ;;; HANDLE: with-handler ;;; This should be defined by the package code, but it isn't. (define (get-struct config-pack struct-name) (let ((s (environment-ref config-pack struct-name))) (cond ((structure? s) s) (else (error "not a structure" s struct-name))))) ;;; ensure-loaded and load-into now write to noise-port anyway (define (load-quietly filename p) (if (not (string? filename)) (error "not a string in load-quietly" filename)) (let-fluid $current-noise-port (make-null-output-port) (lambda () (load-into filename p)))) (define (load-port-quietly port p) (let-fluid $current-noise-port (make-null-output-port) (lambda () (load-port port p)))) (define (really-ensure-loaded noise . structs) (let-fluid $current-noise-port (make-null-output-port) (lambda () (apply ensure-loaded structs)))) (define (load-library-file file lib-dirs script-file package) ; (format (error-output-port) "Load-library-file: ~a ~s\n" file lib-dirs) (cond ((file-name-absolute? file) (load-quietly file package)) ;; Search library dirs for FILE. ((find-library-file file lib-dirs script-file) => (lambda (file) (load-quietly file package))) ; Load it. (else (error "Couldn't find library file" file lib-dirs)))) ;;; The switches: ;;; -o Open the structure in current package. ;;; -n Create new package, make it current package. ;;; -m 's package becomes current package. ;;; ;;; -l Load into current package. ;;; -lm Load into config package. ;;; -le Load into exec package. ;;; -ll As in -lm, but search the library path list. ;;; -lel As in -le, but search the library path list. ;;; ;;; +lp Add onto start of library path list. ;;; lp+ Add onto end of library path list. ;;; +lpe As in +lp, but expand env vars & ~user. ;;; lpe+ As in lp+, but expand env vars & ~user. ;;; +lpsd Add the script-file's directory to front of path list ;;; lpsd+ Add the script-file's directory to end of path list ;;; -lp-clear Clear library path list to (). ;;; -lp-default Reset library path list to system default. ;;; ;;; 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 Call () to start program. ;;; ;;; Terminating switches: ;;; -c Eval , then exit. ;;; -s