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.
···139139 | None -> None
140140 in
141141 let from_tput () =
142142- let ic = Unix.open_process_in "tput cols 2>/dev/null" in
143143- let result = input_line ic |> int_of_string_opt in
144144- ignore (Unix.close_process_in ic);
145145- result
142142+ try
143143+ let ic = Unix.open_process_in "tput cols 2>/dev/null" in
144144+ let result =
145145+ try input_line ic |> int_of_string_opt with End_of_file -> None
146146+ in
147147+ ignore (Unix.close_process_in ic);
148148+ result
149149+ with Unix.Unix_error _ -> None
146150 in
147151 (* Use env if valid (> 10), otherwise try tput, fallback to 80 *)
148152 match from_env with