diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-11-20 21:31:51 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-11-20 21:31:51 -0800 |
commit | d613cde8a2579f8e40248dc3839c39c89de4009e (patch) | |
tree | 4b1e25ae19d7ea812aaa0cef465d9a332ee9a30b /txr.c | |
parent | 2c679f9bd0abcd8412b9162c74a58ba1eace3ed5 (diff) | |
download | txr-d613cde8a2579f8e40248dc3839c39c89de4009e.tar.gz txr-d613cde8a2579f8e40248dc3839c39c89de4009e.tar.bz2 txr-d613cde8a2579f8e40248dc3839c39c89de4009e.zip |
Revive -b option for binding Lisp variables.
* txr.c (txr_main): Implement -b option that takes an
argument. Ensure that -b produces an error if clumped with
other options.
* txr.1: Documented -b var=val.
Diffstat (limited to 'txr.c')
-rw-r--r-- | txr.c | 24 |
1 files changed, 21 insertions, 3 deletions
@@ -728,7 +728,7 @@ int txr_main(int argc, char **argv) } /* Single letter options with args: non-clumping. */ - if (length(arg) == two && find(ref(arg, one), lit("acfepPtC"), nil, nil)) + if (length(arg) == two && find(ref(arg, one), lit("abcfepPtC"), nil, nil)) { val opt = chr_str(arg, one); @@ -749,6 +749,25 @@ int txr_main(int argc, char **argv) if (!do_fixnum_opt(compat, opt, arg)) return EXIT_FAILURE; break; + case 'b': + drop_privilege(); + { + val pair = partition_star(arg, pos(chr('='), arg, nil, nil)); + val sym = lisp_parse(pop(&pair), std_error, + colon_k, lit("cmdline-expr"), colon_k); + val obj = lisp_parse(pop(&pair), std_error, + colon_k, lit("cmdline-expr"), colon_k); + + if (!bindable(sym)) { + format(std_error, + lit("~a: ~s isn't a bindable symbol\n"), + prog_string, sym, nao); + return EXIT_FAILURE; + } + + reg_var(sym, obj); + } + break; case 'c': if (txr_lisp_p) { format(std_error, @@ -827,8 +846,6 @@ int txr_main(int argc, char **argv) case 'q': match_loglevel = 0; break; - case 'b': /* deprecated */ - break; case 'B': opt_print_bindings = 1; break; @@ -861,6 +878,7 @@ int txr_main(int argc, char **argv) stream_set_prop(std_input, real_time_k, nil); break; case 'a': + case 'b': case 'c': case 'e': case 'p': |