summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-02-27 05:05:58 -0800
committerKaz Kylheku <kaz@kylheku.com>2012-02-27 05:05:58 -0800
commit7c1eda9eec81468c7083877f88f94b0dbd3ef068 (patch)
tree018d77d2bee949b185be9ed71cc10e22e60ac490
parent61f40e03c573f995f4cc156e0284096ad30eb692 (diff)
downloadtxr-7c1eda9eec81468c7083877f88f94b0dbd3ef068.tar.gz
txr-7c1eda9eec81468c7083877f88f94b0dbd3ef068.tar.bz2
txr-7c1eda9eec81468c7083877f88f94b0dbd3ef068.zip
* match.c (extract): Check for negative value of opt_nobindings,
which forces the printing. * txr.c (help): Under -b, mention that printing the word false is suppressed also. Added documentation for -B. (main): Implemented -B option. * txr.1: Documented -B option and added clarifying text under -b option explaining the conditions under which bindings are printed.
-rw-r--r--ChangeLog12
-rw-r--r--match.c10
-rw-r--r--txr.110
-rw-r--r--txr.c10
4 files changed, 33 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 8eea6f22..ddfbdabc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2012-02-27 Kaz Kylheku <kaz@kylheku.com>
+
+ * match.c (extract): Check for negative value of opt_nobindings,
+ which forces the printing.
+
+ * txr.c (help): Under -b, mention that printing the word false is
+ suppressed also. Added documentation for -B.
+ (main): Implemented -B option.
+
+ * txr.1: Documented -B option and added clarifying text under -b
+ option explaining the conditions under which bindings are printed.
+
2012-02-26 Kaz Kylheku <kaz@kylheku.com>
Fix the issue properly, once and for all, of how to determine
diff --git a/match.c b/match.c
index 5dda9602..bf6b82a6 100644
--- a/match.c
+++ b/match.c
@@ -3590,12 +3590,10 @@ int extract(val spec, val files, val predefined_bindings)
predefined_bindings,
t, nil)));
- if (!output_produced) {
- if (!opt_nobindings) {
- if (bindings) {
- bindings = nreverse(bindings);
- dump_bindings(bindings);
- }
+ if ((!output_produced && opt_nobindings <= 0) || opt_nobindings < 0) {
+ if (bindings) {
+ bindings = nreverse(bindings);
+ dump_bindings(bindings);
}
if (!success)
diff --git a/txr.1 b/txr.1
index 2307d2f1..7ea141df 100644
--- a/txr.1
+++ b/txr.1
@@ -107,7 +107,15 @@ Suppresses the printing of variable bindings for a successful query, and the
word .
IR false
for a failed query. The program still sets an appropriate
-termination status.
+termination status. Bindings are implicitly suppressed if the TXR query
+performs an output operation on any file stream other than *stddebug*.
+(Internal streams like string streams do not count as output.)
+
+.IP -B
+Force the printing of variable bindings for a successful query, and the
+word .
+IR false
+for a failed query, even if the program produced output.
.IP "-l or --lisp-bindings"
Print the variable bindings in Lisp syntax instead of shell syntax.
diff --git a/txr.c b/txr.c
index 9dc083a9..92893ebe 100644
--- a/txr.c
+++ b/txr.c
@@ -90,8 +90,11 @@ static void help(void)
"-Dvar Predefine variable var, with empty string value.\n"
"-q Quiet: don't report errors during query matching.\n"
"-v Verbose: extra logging from matcher.\n"
-"-b Don't dump list of bindings.\n"
-"-l If dumping bindings, use a Lisp format.\n"
+"-b Don't dump list of bindings, or 'false'\n"
+" on unsuccessful termination.\n"
+"-B Force list of bindings to be dumped, or false\n"
+" if termination is unsuccessful.\n"
+"-l If dumping bindings, use TXR Lisp format.\n"
"-d Debugger mode.\n"
"-a num Generate array variables up to num-dimensions.\n"
" Default is 1. Additional dimensions are fudged\n"
@@ -329,6 +332,9 @@ int txr_main(int argc, char **argv)
case 'b':
opt_nobindings = 1;
break;
+ case 'B':
+ opt_nobindings = -1;
+ break;
case 'l':
opt_lisp_bindings = 1;
break;