Index: svnmerge.py
===================================================================
--- svnmerge.py	(revision 27347)
+++ svnmerge.py	(working copy)
@@ -182,11 +182,17 @@
     except ImportError:
         pass
 
-    # Parse the output of stty -a
-    out = os.popen("stty -a").read()
-    m = re.search(r"columns (\d+);", out)
-    if m:
-        return int(m.group(1))
+    # Parse the output of stty -a, if we have a terminal type and if
+    # fd 0 is actually a terminal
+    if os.environ.get('TERM', '') and os.isatty(1):
+        try:
+            out = os.popen("stty -a").read()
+        except:
+            # ignore all errors
+            out = ''
+        m = re.search(r"columns (\d+);", out)
+        if m:
+            return int(m.group(1))
 
     # sensible default
     return 80
