Terminal styling and layout widgets for OCaml (tables, trees, panels, colors)
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocaml-tty: handle End_of_file and Unix errors in terminal_width

Guard tput invocation against End_of_file (when tput produces no
output) and Unix_error (when tput is unavailable), returning None
gracefully in both cases.

+8 -4
+8 -4
lib/width.ml
··· 139 139 | None -> None 140 140 in 141 141 let from_tput () = 142 - let ic = Unix.open_process_in "tput cols 2>/dev/null" in 143 - let result = input_line ic |> int_of_string_opt in 144 - ignore (Unix.close_process_in ic); 145 - result 142 + try 143 + let ic = Unix.open_process_in "tput cols 2>/dev/null" in 144 + let result = 145 + try input_line ic |> int_of_string_opt with End_of_file -> None 146 + in 147 + ignore (Unix.close_process_in ic); 148 + result 149 + with Unix.Unix_error _ -> None 146 150 in 147 151 (* Use env if valid (> 10), otherwise try tput, fallback to 80 *) 148 152 match from_env with