summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-01-07 23:57:46 +0100
committerwm4 <wm4@nowhere>2014-01-15 20:49:42 +0100
commit86e7c3defb8a58f8202e63ba2e34d46c559853c2 (patch)
tree013f61f151119142c73f634c9a64c93394641475
parent0fe1385d80de4acf7d600700e0fe8ed1d884c172 (diff)
downloadmpv-86e7c3defb8a58f8202e63ba2e34d46c559853c2.tar.bz2
mpv-86e7c3defb8a58f8202e63ba2e34d46c559853c2.tar.xz
terminal: don't initialize termcap etc. if stdout is not a terminal
Otherwise, it seems one of the term* libraries will write escape sequences to stdout, for whatever reason.
-rw-r--r--osdep/terminal-unix.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/osdep/terminal-unix.c b/osdep/terminal-unix.c
index 03f2360916..193cd8557f 100644
--- a/osdep/terminal-unix.c
+++ b/osdep/terminal-unix.c
@@ -47,6 +47,8 @@
#include "input/keycodes.h"
#include "terminal.h"
+static int use_terminal;
+
#if HAVE_TERMIOS
static volatile struct termios tio_orig;
static volatile int tio_orig_set;
@@ -454,7 +456,7 @@ static volatile int getch2_enabled = 0;
static void do_activate_getch2(void)
{
- if (getch2_active)
+ if (getch2_active || !use_terminal)
return;
#if HAVE_TERMINFO || HAVE_TERMCAP
@@ -612,6 +614,8 @@ void terminal_setup_stdin_cmd_input(struct input_ctx *ictx)
int terminal_init(void)
{
- load_termcap(NULL);
+ use_terminal = isatty(1);
+ if (use_terminal)
+ load_termcap(NULL);
return 0;
}