diff options
author | Andreas Kling <kling@serenityos.org> | 2020-01-19 13:51:43 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-01-19 13:52:44 +0100 |
commit | 6ca1a46afd9eeb0f7a4d6cdab440bb7f20912290 (patch) | |
tree | 244637adde5d4684f2ba5d5f836e000868976f4f /Shell | |
parent | 6eab7b398d2ce658b56f2650c721454a4e41fa2b (diff) | |
download | serenity-6ca1a46afd9eeb0f7a4d6cdab440bb7f20912290.zip |
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.
Diffstat (limited to 'Shell')
-rw-r--r-- | Shell/LineEditor.cpp | 7 |
1 files 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() |