diff options
-rw-r--r-- | eval.c | 2 | ||||
-rw-r--r-- | eval.h | 1 | ||||
-rw-r--r-- | txr.1 | 36 | ||||
-rw-r--r-- | txr.c | 5 |
4 files changed, 30 insertions, 14 deletions
@@ -5246,7 +5246,7 @@ static val do_retf(val ret, struct args *args) return ret; } -static val retf(val ret) +val retf(val ret) { return func_f0v(ret, do_retf); } @@ -80,6 +80,7 @@ val mapcarv(val fun, struct args *lists); val mapcarl(val fun, val list_of_lists); val lazy_mapcar(val fun, val list); val generate(val while_pred, val gen_fun); +val retf(val ret); val prinl(val obj, val stream); val pprinl(val obj, val stream); val tprint(val obj, val out); @@ -769,10 +769,10 @@ option (extended .codn --args ) is like .code --args -but must be followed by an argument. The argument is substituted -in place of occurrences of +but must be followed by an argument. The argument is removed from +the argument list and substituted in place of occurrences of .code {} -in the +among the arguments expanded from the .code --eargs syntax. @@ -1136,11 +1136,17 @@ The mechanism allows an additional flexibility. An .code --eargs argument must be followed by one more argument. -Occurrences of the two-character sequence + +After +.code --eargs +performs the argument splitting in the same manner as +.codn --args , +any of the arguments which it produces which are the +two-character sequence .code {} -in the encoded argument string are replaced with that -following argument. This replacement occurs after -the argument splitting. +are replaced with that following argument. Whether +or not the replacement occurs, that following argument +is then removed. Example: @@ -1172,9 +1178,11 @@ processing takes place, firstly the argument sequence -B {} --foo 42 .cble -is produced. Then, all occurrences of +is produced by splitting into four fields using the +.code : +character as the separator. Then, within these four fields, all occurrences of .code {} -are replaced with +are replaced with the following argument .codn script.txr , resulting in: @@ -1182,7 +1190,15 @@ resulting in: -B script.txr --foo 42 .cble -The resulting \*(TX invocation is +Furthermore, that +.code script.txr +argument is removed from the remaining argument list. + +The four arguments are then substituted in place of the original +.code --eargs:-B:{}:--foo:42 +syntax. + +The resulting \*(TX invocation is, therefore: .cblk /usr/bin/txr -B script.txr --foo 42 a b c @@ -573,9 +573,8 @@ int txr_main(int argc, char **argv) } 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), + arg_list = append2(mapcar(iffi(curry_12_2(equal_f, lit("{}")), + retf(arg2), nil), split_str(arg, sep)), arg_list); set(eff_arg_tail, butlastn(one, deref(eff_arg_tail))); |