summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--txr.124
-rw-r--r--txr.c21
3 files changed, 42 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 49df5cca..5576dced 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2015-03-17 Kaz Kylheku <kaz@kylheku.com>
+
+ * txr.c (help): Added missing documentation for -e and -p.
+ Also documented -P.
+ (txr_main): New option implemented, -P.
+
+ * txr.1: Document -P, and clean up -e and -p documentation.
+
2015-03-11 Kaz Kylheku <kaz@kylheku.com>
Version 105.
diff --git a/txr.1 b/txr.1
index ddd334b7..bb8efb4a 100644
--- a/txr.1
+++ b/txr.1
@@ -596,15 +596,27 @@ its value. Can be specified more than once. The
.meta query-file
argument becomes optional if
.code -e
-is used at least once.
+is used at least once. If the evaluation of every
+.meta expression
+evaluated this way terminates normally, and there is no
+.meta query-file
+argument, then \(TX terminates with a successful status.
.meIP -p < expression
-Evaluates a \*(TL expression and prints its value. Can be specified more
-than once. The
-.meta query-file
-argument becomes optional if
+Just like
+.code -e
+but prints the value of
+.meta expression
+using the
+.code prinl
+function.
+
+.meIP -P < expression
+Like
.code -p
-is used at least once.
+but prints using the
+.code pprinl
+function.
.meIP -C < number
.meIP >> --compat= number
diff --git a/txr.c b/txr.c
index cd01a439..1a33cfec 100644
--- a/txr.c
+++ b/txr.c
@@ -122,6 +122,11 @@ static void help(void)
" option, instead of the query-file argument.\n"
" This allows #! scripts to pass options through\n"
" to the utility.\n"
+"-e expression Evaluate TXR Lisp expression. Can be specified\n"
+" multiple times. The query-file arg becomes optional.\n"
+"-p expression Like -e, but prints the result of the expression\n"
+" using the prinl function.\n"
+"-P expression Like -p, but prints using pprinl.\n"
"-C N Request backward-compatible behavior to the\n"
" specified version of TXR.\n"
"--help You already know!\n"
@@ -498,7 +503,7 @@ int txr_main(int argc, char **argv)
/* Single letter options with args: non-clumping. */
- if (length(arg) == two && find(ref(arg, one), lit("acfepC"), nil, nil))
+ if (length(arg) == two && find(ref(arg, one), lit("acfepPC"), nil, nil))
{
val opt = chr_str(arg, one);
@@ -530,10 +535,15 @@ int txr_main(int argc, char **argv)
evaled = t;
break;
case 'p':
- obj_print(eval_intrinsic(lisp_parse(arg, std_error, colon_k),
- make_env(bindings, nil, nil)), std_output);
- put_char(chr('\n'), std_output);
- evaled = t;
+ case 'P':
+ {
+ val (*pf)(val obj, val out) = if3(c_chr(opt) == 'p',
+ obj_print, obj_pprint);
+ pf(eval_intrinsic(lisp_parse(arg, std_error, colon_k),
+ make_env(bindings, nil, nil)), std_output);
+ put_char(chr('\n'), std_output);
+ evaled = t;
+ }
break;
}
@@ -577,6 +587,7 @@ int txr_main(int argc, char **argv)
case 'c':
case 'e':
case 'p':
+ case 'P':
case 'f':
case 'C':
case 'D':