mes: Support -c EXPR.
* mes/module/mes/boot-0.scm.in: Support -c EXPR.
This commit is contained in:
parent
b969c08205
commit
1d56567c50
|
@ -212,6 +212,7 @@
|
||||||
(define (parse-opts args)
|
(define (parse-opts args)
|
||||||
(let* ((option-spec
|
(let* ((option-spec
|
||||||
'((no-auto-compile)
|
'((no-auto-compile)
|
||||||
|
(command (single-char #\c) (value #t))
|
||||||
(compiled-path (single-char #\C) (value #t))
|
(compiled-path (single-char #\C) (value #t))
|
||||||
(help (single-char #\h))
|
(help (single-char #\h))
|
||||||
(load-path (single-char #\L) (value #t))
|
(load-path (single-char #\L) (value #t))
|
||||||
|
@ -224,6 +225,7 @@
|
||||||
(let* ((s-index (list-index source-arg? %argv))
|
(let* ((s-index (list-index source-arg? %argv))
|
||||||
(args (if s-index (list-head %argv (+ s-index 2)) %argv))
|
(args (if s-index (list-head %argv (+ s-index 2)) %argv))
|
||||||
(options (parse-opts args))
|
(options (parse-opts args))
|
||||||
|
(command (option-ref options 'command #f))
|
||||||
(main (option-ref options 'main #f))
|
(main (option-ref options 'main #f))
|
||||||
(source (option-ref options 'source #f))
|
(source (option-ref options 'source #f))
|
||||||
(files (if s-index (list-tail %argv (+ s-index 1))
|
(files (if s-index (list-tail %argv (+ s-index 1))
|
||||||
|
@ -240,6 +242,7 @@
|
||||||
Evaluate code with Mes, interactively or from a script.
|
Evaluate code with Mes, interactively or from a script.
|
||||||
|
|
||||||
[-s] FILE load source code from FILE, and exit
|
[-s] FILE load source code from FILE, and exit
|
||||||
|
-c EXPR evalute expression EXPR, and exit
|
||||||
-- stop scanning arguments; run interactively
|
-- stop scanning arguments; run interactively
|
||||||
|
|
||||||
The above switches stop argument processing, and pass all
|
The above switches stop argument processing, and pass all
|
||||||
|
@ -262,10 +265,16 @@ General help using GNU software: <http://gnu.org/gethelp/>
|
||||||
" (or (and usage? (current-error-port)) (current-output-port)))
|
" (or (and usage? (current-error-port)) (current-output-port)))
|
||||||
(exit (or (and usage? 2) 0)))
|
(exit (or (and usage? 2) 0)))
|
||||||
options)
|
options)
|
||||||
(if main (set! %main main))
|
|
||||||
(and=> (option-ref options 'load-path #f)
|
(and=> (option-ref options 'load-path #f)
|
||||||
(lambda (dir)
|
(lambda (dir)
|
||||||
(setenv "GUILE_LOAD_PATH" (string-append dir ":" (getenv "GUILE_LOAD_PATH")))))
|
(setenv "GUILE_LOAD_PATH" (string-append dir ":" (getenv "GUILE_LOAD_PATH")))))
|
||||||
|
(when command
|
||||||
|
(let* ((prev (set-current-input-port (open-input-string command)))
|
||||||
|
(expr (read-input-file-env (current-module)))
|
||||||
|
(set-current-input-port prev))
|
||||||
|
(primitive-eval expr)
|
||||||
|
(exit 0)))
|
||||||
|
(when main (set! %main main))
|
||||||
(cond ((pair? files)
|
(cond ((pair? files)
|
||||||
(let* ((file (car files))
|
(let* ((file (car files))
|
||||||
(port (if (equal? file "-") 0
|
(port (if (equal? file "-") 0
|
||||||
|
|
Loading…
Reference in a new issue