[Libguestfs] [PATCH] mllib: use Unix.isatty

Pino Toscano ptoscano at redhat.com
Tue Nov 25 10:59:06 UTC 2014


Make use of Unix.isatty instead of our TTY.isatty_stdout, as the
supported OCaml provides the former already.
---
 mllib/common_utils.ml | 10 +++++-----
 mllib/progress.ml     |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml
index 295981c..9fcd8dd 100644
--- a/mllib/common_utils.ml
+++ b/mllib/common_utils.ml
@@ -207,15 +207,15 @@ let rec combine3 xs ys zs =
 
 (* ANSI terminal colours. *)
 let ansi_green ?(chan = stdout) () =
-  if TTY.isatty_stdout () then output_string chan "\x1b[0;32m"
+  if Unix.isatty Unix.stdout then output_string chan "\x1b[0;32m"
 let ansi_red ?(chan = stdout) () =
-  if TTY.isatty_stdout () then output_string chan "\x1b[1;31m"
+  if Unix.isatty Unix.stdout then output_string chan "\x1b[1;31m"
 let ansi_blue ?(chan = stdout) () =
-  if TTY.isatty_stdout () then output_string chan "\x1b[1;34m"
+  if Unix.isatty Unix.stdout then output_string chan "\x1b[1;34m"
 let ansi_magenta ?(chan = stdout) () =
-  if TTY.isatty_stdout () then output_string chan "\x1b[1;35m"
+  if Unix.isatty Unix.stdout then output_string chan "\x1b[1;35m"
 let ansi_restore ?(chan = stdout) () =
-  if TTY.isatty_stdout () then output_string chan "\x1b[0m"
+  if Unix.isatty Unix.stdout then output_string chan "\x1b[0m"
 
 (* Timestamped progress messages, used for ordinary messages when not
  * --quiet.
diff --git a/mllib/progress.ml b/mllib/progress.ml
index 194120e..8cf5875 100644
--- a/mllib/progress.ml
+++ b/mllib/progress.ml
@@ -33,7 +33,7 @@ let set_up_progress_bar ?(machine_readable = false) (g : Guestfs.guestfs) =
   (* Only display progress bars if the machine_readable flag is set or
    * the output is a tty.
    *)
-  if machine_readable || TTY.isatty_stdout () then (
+  if machine_readable || Unix.isatty Unix.stdout then (
     (* Initialize the C mini library. *)
     let bar = progress_bar_init ~machine_readable in
 
-- 
1.9.3




More information about the Libguestfs mailing list