Fixed an issue where "command source" would not do the right thing:
- empty lines in init files would repeat previous command and cause errors to be displayed
- all options to control showing the command, its output, if it should stop on error or continue, weren't being obeyed.

llvm-svn: 200860
diff --git a/lldb/source/Host/common/File.cpp b/lldb/source/Host/common/File.cpp
index ab61b39..dcb272a 100644
--- a/lldb/source/Host/common/File.cpp
+++ b/lldb/source/Host/common/File.cpp
@@ -13,7 +13,9 @@
 #include <fcntl.h>
 #include <limits.h>
 #include <stdarg.h>
+#include <stdio.h>
 #include <sys/stat.h>
+#include <sys/ioctl.h>
 
 #ifdef _WIN32
 #include "lldb/Host/windows/windows.h"
@@ -78,7 +80,9 @@
     m_stream (kInvalidStream),
     m_options (),
     m_own_stream (false),
-    m_own_descriptor (false)
+    m_own_descriptor (false),
+    m_is_interactive (eLazyBoolCalculate),
+    m_is_real_terminal (eLazyBoolCalculate)
 {
     Open (path, options, permissions);
 }
@@ -90,7 +94,10 @@
     m_stream (kInvalidStream),
     m_options (0),
     m_own_stream (false),
-    m_own_descriptor (false)
+    m_own_descriptor (false),
+    m_is_interactive (eLazyBoolCalculate),
+    m_is_real_terminal (eLazyBoolCalculate)
+
 {
     if (filespec)
     {
@@ -103,7 +110,9 @@
     m_stream (kInvalidStream),
     m_options (0),
     m_own_stream (false),
-    m_own_descriptor (false)
+    m_own_descriptor (false),
+    m_is_interactive (eLazyBoolCalculate),
+    m_is_real_terminal (eLazyBoolCalculate)
 {
     Duplicate (rhs);
 }
@@ -371,6 +380,8 @@
     m_options = 0;
     m_own_stream = false;
     m_own_descriptor = false;
+    m_is_interactive = eLazyBoolCalculate;
+    m_is_real_terminal = eLazyBoolCalculate;
     return error;
 }
 
@@ -866,3 +877,41 @@
 
     return mode;
 }
+
+void
+File::CalculateInteractiveAndTerminal ()
+{
+    const int fd = GetDescriptor();
+    if (fd >= 0)
+    {
+        m_is_interactive = eLazyBoolNo;
+        m_is_real_terminal = eLazyBoolNo;
+        if (isatty(fd))
+        {
+            m_is_interactive = eLazyBoolYes;
+            struct winsize window_size;
+            if (::ioctl (fd, TIOCGWINSZ, &window_size) == 0)
+            {
+                if (window_size.ws_col > 0)
+                    m_is_real_terminal = eLazyBoolYes;
+            }
+        }
+    }
+}
+
+bool
+File::GetIsInteractive ()
+{
+    if (m_is_interactive == eLazyBoolCalculate)
+        CalculateInteractiveAndTerminal ();
+    return m_is_interactive == eLazyBoolYes;
+}
+
+bool
+File::GetIsRealTerminal ()
+{
+    if (m_is_real_terminal == eLazyBoolCalculate)
+        CalculateInteractiveAndTerminal();
+    return m_is_real_terminal == eLazyBoolYes;
+}
+