mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
RHEL 5: Replacement for 'Unix.isatty stdout' for old OCaml versions.
Unix.isatty missing on RHEL 5-era OCaml 3.09.3.
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <locale.h>
|
||||
|
||||
#include <caml/alloc.h>
|
||||
@@ -103,3 +104,12 @@ virt_resize_progress_bar_set (value barv,
|
||||
|
||||
CAMLreturn (Val_unit);
|
||||
}
|
||||
|
||||
/* RHEL 5-era ocaml didn't have Unix.isatty. */
|
||||
value
|
||||
virt_resize_isatty_stdout (value unitv)
|
||||
{
|
||||
CAMLparam1 (unitv);
|
||||
|
||||
CAMLreturn (isatty(1) ? Val_true : Val_false);
|
||||
}
|
||||
|
||||
@@ -28,12 +28,13 @@ external progress_bar_reset : progress_bar -> unit
|
||||
= "virt_resize_progress_bar_reset"
|
||||
external progress_bar_set : progress_bar -> int64 -> int64 -> unit
|
||||
= "virt_resize_progress_bar_set"
|
||||
external isatty_stdout : unit -> bool = "virt_resize_isatty_stdout"
|
||||
|
||||
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 || isatty stdout then (
|
||||
if machine_readable || isatty_stdout () then (
|
||||
(* Initialize the C mini library. *)
|
||||
let bar = progress_bar_init ~machine_readable in
|
||||
|
||||
|
||||
Reference in New Issue
Block a user