about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-12-31 15:30:41 -0500
committerJune McEnroe <june@causal.agency>2019-12-31 15:30:41 -0500
commit5515a70dabf9af1b63727734b5ccafbce009cec5 (patch)
treec2515edc20e7589b54c904d47144c80649d9c6b8
parentSet up pager pipe (diff)
downloadlitterbox-5515a70dabf9af1b63727734b5ccafbce009cec5.tar.gz
litterbox-5515a70dabf9af1b63727734b5ccafbce009cec5.zip
Only enable highlighting on terminal output
-rw-r--r--scoop.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/scoop.c b/scoop.c
index 0b652d9..f32da90 100644
--- a/scoop.c
+++ b/scoop.c
@@ -187,9 +187,14 @@ int main(int argc, char *argv[]) {
 	if (search) dbBindText(stmt, ":search", search);
 	dbBindInt(stmt, ":limit", limit);
 
-	// FIXME: Conditional on terminal.
-	dbBindText(stmt, ":open", "\33[33m");
-	dbBindText(stmt, ":close", "\33[m");
+	if (tty) {
+		dbBindText(stmt, ":open", "\33[33m");
+		dbBindText(stmt, ":close", "\33[m");
+	} else {
+		// XXX: If you leave these NULL fts5 segfaults...
+		dbBindText(stmt, ":open", "");
+		dbBindText(stmt, ":close", "");
+	}
 
 	if (verbose) {
 		char *expand = sqlite3_expanded_sql(stmt);