From 9ab72ac045ea3b258bed792db89af2b6ae99356f Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Wed, 14 May 2014 16:12:54 +0300 Subject: [PATCH] ProcessStub: Preserve the TERM environment variable * If Creator is not executed from terminal, this value is missing. * If it is executed from a terminal of another type than the stub it might be wrong. Change-Id: Ia6bd1dd59be04e01398ed5cdffff3080539b10ef Reviewed-by: Oswald Buddenhagen --- src/libs/utils/consoleprocess_unix.cpp | 1 + src/libs/utils/process_stub_unix.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libs/utils/consoleprocess_unix.cpp b/src/libs/utils/consoleprocess_unix.cpp index 05396dac036..1374d06f16b 100644 --- a/src/libs/utils/consoleprocess_unix.cpp +++ b/src/libs/utils/consoleprocess_unix.cpp @@ -124,6 +124,7 @@ bool ConsoleProcess::start(const QString &program, const QString &args) return false; } + d->m_environment.unset(QLatin1String("TERM")); QStringList env = d->m_environment.toStringList(); if (!env.isEmpty()) { d->m_tempFile = new QTemporaryFile(); diff --git a/src/libs/utils/process_stub_unix.c b/src/libs/utils/process_stub_unix.c index b061f7f8173..4a9df676b5c 100644 --- a/src/libs/utils/process_stub_unix.c +++ b/src/libs/utils/process_stub_unix.c @@ -206,7 +206,7 @@ int main(int argc, char *argv[]) if (*argv[ArgEnv]) { FILE *envFd; - char *envdata, *edp; + char *envdata, *edp, *termEnv; long size; int count; if (!(envFd = fopen(argv[ArgEnv], "r"))) { @@ -225,11 +225,13 @@ int main(int argc, char *argv[]) fclose(envFd); for (count = 0, edp = envdata; edp < envdata + size; ++count) edp += strlen(edp) + 1; - env = malloc((count + 1) * sizeof(char *)); + env = malloc((count + 2) * sizeof(char *)); for (count = 0, edp = envdata; edp < envdata + size; ++count) { env[count] = edp; edp += strlen(edp) + 1; } + if ((termEnv = getenv("TERM"))) + env[count++] = termEnv - 5; env[count] = 0; }