mes: Support -c EXPR.

* mes/module/mes/boot-0.scm.in: Support -c EXPR.
This commit is contained in:
Jan (janneke) Nieuwenhuizen 2019-05-16 00:04:45 +02:00 committed by Jan Nieuwenhuizen
parent b969c08205
commit 1d56567c50
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273

View file

@ -212,6 +212,7 @@
(define (parse-opts args)
(let* ((option-spec
'((no-auto-compile)
(command (single-char #\c) (value #t))
(compiled-path (single-char #\C) (value #t))
(help (single-char #\h))
(load-path (single-char #\L) (value #t))
@ -224,6 +225,7 @@
(let* ((s-index (list-index source-arg? %argv))
(args (if s-index (list-head %argv (+ s-index 2)) %argv))
(options (parse-opts args))
(command (option-ref options 'command #f))
(main (option-ref options 'main #f))
(source (option-ref options 'source #f))
(files (if s-index (list-tail %argv (+ s-index 1))
@ -240,21 +242,22 @@
Evaluate code with Mes, interactively or from a script.
[-s] FILE load source code from FILE, and exit
-c EXPR evalute expression EXPR, and exit
-- stop scanning arguments; run interactively
The above switches stop argument processing, and pass all
remaining arguments as the value of (command-line).
-e,--main=MAIN after reading script, apply MAIN to command-line arguments
-e, --main=MAIN after reading script, apply MAIN to command-line arguments
-h, --help display this help and exit
-L,--load-path=DIR add DIR to the front of the module load path
-L, --load-path=DIR add DIR to the front of the module load path
-v, --version display version information and exit
Ignored for Guile compatibility:
--auto-compile
--fresh-auto-compile
--no-auto-compile
-C,--compiled-path=DIR
-C, --compiled-path=DIR
Report bugs to: bug-mes@gnu.org
GNU Mes home page: <http://gnu.org/software/mes/>
@ -262,10 +265,16 @@ General help using GNU software: <http://gnu.org/gethelp/>
" (or (and usage? (current-error-port)) (current-output-port)))
(exit (or (and usage? 2) 0)))
options)
(if main (set! %main main))
(and=> (option-ref options 'load-path #f)
(lambda (dir)
(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)
(let* ((file (car files))
(port (if (equal? file "-") 0