Skip to content

Commit

Permalink
Shell: Don't crash when stdout is not a TTY
Browse files Browse the repository at this point in the history
Let's just pretend we have 80 columns while running non-interactively.
There are definitely nicer solutions here, and we should find them.
  • Loading branch information
awesomekling committed Jan 19, 2020
1 parent 6eab7b3 commit 6ca1a46
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Shell/LineEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@
LineEditor::LineEditor()
{
struct winsize ws;
int rc = ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws);
ASSERT(rc == 0);
m_num_columns = ws.ws_col;
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) < 0)
m_num_columns = 80;
else
m_num_columns = ws.ws_col;
}

LineEditor::~LineEditor()
Expand Down

0 comments on commit 6ca1a46

Please sign in to comment.