summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2018-12-09 20:59:11 +0100
committerPhilipp Gesang <phg@phi-gamma.net>2018-12-09 20:59:13 +0100
commit5835b73456898c7bd48d3ed9ec2539c1b560f9b8 (patch)
treef03210622536c66f9cf061b6a9bc50773d9fabe8 /util
parent039f4068c0e991b79769426486147d7851d5d6fd (diff)
downloadocaml-sid-5835b73456898c7bd48d3ed9ec2539c1b560f9b8.tar.gz
sidparse: flush linewise when run interactively
Provide immediate feedback on stdout when running in an interactive terminal the assumption being we’re dealing with a human.
Diffstat (limited to 'util')
-rw-r--r--util/sidparse.ml5
1 files changed, 4 insertions, 1 deletions
diff --git a/util/sidparse.ml b/util/sidparse.ml
index 8027692..0440751 100644
--- a/util/sidparse.ml
+++ b/util/sidparse.ml
@@ -1,5 +1,7 @@
(* SPDX-License-Identifier: LGPL-3.0-only WITH OCaml-LGPL-linking-exception *)
+let interactive = Unix.(isatty stdin)
+
let err q v =
match q, v with
| true, _ -> Printf.ifprintf stdout
@@ -61,6 +63,7 @@ let traverse q v next =
| `Done s -> begin
if n = 0 then header q v;
emit q v s;
+ if interactive then flush_all ();
aux (n + 1) ne
end
end
@@ -71,7 +74,7 @@ let sidparse validate quiet args =
let next =
match args with
| [] -> begin
- if Unix.(isatty stdin) then
+ if interactive then
err quiet validate "reading input from stdin\n%!";
from_stdin
end