summaryrefslogtreecommitdiffstats
path: root/txr.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-02-02 16:54:39 -0800
committerKaz Kylheku <kaz@kylheku.com>2016-02-02 16:54:39 -0800
commita9e1bec854f6c0343dfb2cb32879cdb31d84f209 (patch)
tree2ca597141ea63716eca2e5cf116634857bf12456 /txr.c
parent22ff849e9602f1f7120e504d4295f4e9854e0c88 (diff)
downloadtxr-a9e1bec854f6c0343dfb2cb32879cdb31d84f209.tar.gz
txr-a9e1bec854f6c0343dfb2cb32879cdb31d84f209.tar.bz2
txr-a9e1bec854f6c0343dfb2cb32879cdb31d84f209.zip
Adding --eargs mechanism.
* txr.c (txr_main): Implement --eargs. * txr.1: Documented.
Diffstat (limited to 'txr.c')
-rw-r--r--txr.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/txr.c b/txr.c
index 476362ae..d9c2b166 100644
--- a/txr.c
+++ b/txr.c
@@ -474,7 +474,28 @@ int txr_main(int argc, char **argv)
continue;
}
- /* Odd case 2: -Dfoo=bar syntax. */
+ /* Odd case 2: --eargs is followed by an arbitrary delimiting
+ * character, not necessarily = */
+ if (match_str(arg, lit("--eargs"), zero) && ge(length(arg), num(8))) {
+ val sep = sub_str(arg, num(7), num(8));
+ val arg2;
+ if (!arg_list) {
+ format(std_error,
+ lit("~a: --eargs=[...] must be followed by an argument\n"),
+ prog_string, nao);
+ return EXIT_FAILURE;
+ }
+ arg = sub_str(arg, num(8), nil);
+ arg2 = upop(&arg_list, &arg_undo);
+ arg_list = append2(mapcar(curry_123_3(func_n3(regsub),
+ regex_compile(lit("{}"), nil),
+ arg2),
+ split_str(arg, sep)),
+ arg_list);
+ continue;
+ }
+
+ /* Odd case 3: -Dfoo=bar syntax. */
if (equal(sub(arg, zero, two), lit("-D"))) {
val dopt_arg = sub(arg, two, t);
cons_bind(var, def, split_str(dopt_arg, lit("=")));