OCamlPro/ocp-build — pull request #61 by jirkamarsik (2014-10-27 17:42:44+00:00)
Title: Fixed an unhandled Not_found exception when probing the terminal's capabilities

I have packaged ocp-build for Nix (I will submit a PR to Nixpkgs tomorrow), but while doing so, I ran into the following bug.

If `stty` returns a non-zero exit code, the code opts out of using `stty` to determine the terminal width by throwing a Not_found exception. However, this exception is not accounted for in the next link of the try-with chain and thus terminates the search prematurely, crashing ocp-build, without checking $COLUMNS or falling back to the default value 80.

This behavior can be witnessed when trying to package ocp-build for Nix. In the sandbox, $TERM is not defined and `tput` and `stty` both fail, which is especially inconvenient since the bug is already present in the bootstrap executable.