core: Expose command line.
* mes.c (scm_symbol_argv): New symbol (main): Use it to add argv to environment. * module/mes/base.mes (command-line): New function.
This commit is contained in:
parent
e1fa4ed8be
commit
d0e222dac3
8
mes.c
8
mes.c
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* Mes --- Maxwell Equations of Software
|
* Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2016,2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of Mes.
|
* This file is part of Mes.
|
||||||
*
|
*
|
||||||
|
@ -102,6 +102,7 @@ scm scm_symbol_primitive_load = {SYMBOL, "primitive-load"};
|
||||||
scm scm_symbol_read_input_file = {SYMBOL, "read-input-file"};
|
scm scm_symbol_read_input_file = {SYMBOL, "read-input-file"};
|
||||||
scm scm_symbol_write = {SYMBOL, "write"};
|
scm scm_symbol_write = {SYMBOL, "write"};
|
||||||
scm scm_symbol_display = {SYMBOL, "display"};
|
scm scm_symbol_display = {SYMBOL, "display"};
|
||||||
|
scm scm_symbol_argv = {SYMBOL, "argv"};
|
||||||
|
|
||||||
scm scm_symbol_mes_version = {SYMBOL, "%version"};
|
scm scm_symbol_mes_version = {SYMBOL, "%version"};
|
||||||
scm scm_symbol_mes_prefix = {SYMBOL, "%prefix"};
|
scm scm_symbol_mes_prefix = {SYMBOL, "%prefix"};
|
||||||
|
@ -1020,6 +1021,11 @@ main (int argc, char *argv[])
|
||||||
SCM program = (argc > 1 && !strcmp (argv[1], "--load"))
|
SCM program = (argc > 1 && !strcmp (argv[1], "--load"))
|
||||||
? bload_env (r0) : load_env (r0);
|
? bload_env (r0) : load_env (r0);
|
||||||
if (argc > 1 && !strcmp (argv[1], "--dump")) return dump ();
|
if (argc > 1 && !strcmp (argv[1], "--dump")) return dump ();
|
||||||
|
|
||||||
|
SCM lst = cell_nil;
|
||||||
|
for (int i=argc; i; i--) lst = cons (MAKE_STRING (cstring_to_list (argv[i-1])), lst);
|
||||||
|
r0 = acons (cell_symbol_argv, lst, r0);
|
||||||
|
|
||||||
stderr_ (begin_env (program, r0));
|
stderr_ (begin_env (program, r0));
|
||||||
fputs ("", stderr);
|
fputs ("", stderr);
|
||||||
gc (g_stack);
|
gc (g_stack);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
;;; -*-scheme-*-
|
;;; -*-scheme-*-
|
||||||
|
|
||||||
;;; Mes --- Maxwell Equations of Software
|
;;; Mes --- Maxwell Equations of Software
|
||||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
;;; Copyright © 2016,2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of Mes.
|
;;; This file is part of Mes.
|
||||||
;;;
|
;;;
|
||||||
|
@ -42,6 +42,8 @@
|
||||||
|
|
||||||
(define (identity x) x)
|
(define (identity x) x)
|
||||||
|
|
||||||
|
(define (command-line) argv)
|
||||||
|
|
||||||
(define-macro (or . x)
|
(define-macro (or . x)
|
||||||
(if (null? x) #f
|
(if (null? x) #f
|
||||||
(if (null? (cdr x)) (car x)
|
(if (null? (cdr x)) (car x)
|
||||||
|
|
Loading…
Reference in a new issue