Explorar o código

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.
Andreas Kling %!s(int64=5) %!d(string=hai) anos
pai
achega
6ca1a46afd
Modificáronse 1 ficheiros con 4 adicións e 3 borrados
  1. 4 3
      Shell/LineEditor.cpp

+ 4 - 3
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()