peterh / liner

Pure Go line editor with history, inspired by linenoise
MIT License
1.04k stars 132 forks source link

Fix the output redirect check when the number of columns reported is zero #75

Closed jsternberg closed 8 years ago

jsternberg commented 8 years ago

Inside of Docker the output terminal will sometimes report a terminal with zero columns when attempting to get terminal info for standard out and then will resize the terminal triggering a SIGWINCH. The return value check was incorrect as it never casted the return value and the if statement functionally didn't do anything even if it was correct.

As the intention is to determine if the terminal is a TTY, this function now returns a boolean that indicates if the ioctl() call succeeded or not rather than checking the number of columns to see if the output is a terminal (as it can be zero and resized).

peterh commented 8 years ago

Thanks for the patch, and for the detailed description.