From 6ca1a46afd9eeb0f7a4d6cdab440bb7f20912290 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 19 Jan 2020 13:51:43 +0100 Subject: [PATCH] Shell: Don't crash when stdout is not a TTY Let's just pretend we have 80 columns while running non-interactively. There are definitely nicer solutions here, and we should find them. --- Shell/LineEditor.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Shell/LineEditor.cpp b/Shell/LineEditor.cpp index bc260a52dd..0984a93900 100644 --- a/Shell/LineEditor.cpp +++ b/Shell/LineEditor.cpp @@ -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()