diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2020-02-15 23:24:16 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2020-02-15 23:30:12 +0530 |
commit | 96020b0a7431150e7257b7dda032ec4497cd5b6a (patch) | |
tree | b1a3b0a5665a8d83833060374ed40f431a68cb1a | |
parent | a64a3a52bdca4549c5b0deb55d130de2ade912ed (diff) | |
download | meson-nirbheek/avoid-git-colors-getting-messed-up-omg-again.tar.gz |
Popen_safe: Always re-setup the console colorsnirbheek/avoid-git-colors-getting-messed-up-omg-again
-rw-r--r-- | mesonbuild/mesonlib.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index f3c07591f..e09d123b9 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -1084,10 +1084,15 @@ def Popen_safe(args: T.List[str], write: T.Optional[str] = None, if 'stdin' not in kwargs: kwargs['stdin'] = subprocess.DEVNULL if sys.version_info < (3, 6) or not sys.stdout.encoding or encoding.upper() != 'UTF-8': - return Popen_safe_legacy(args, write=write, stdout=stdout, stderr=stderr, **kwargs) - p = subprocess.Popen(args, universal_newlines=True, close_fds=False, - stdout=stdout, stderr=stderr, **kwargs) - o, e = p.communicate(write) + p, o, e = Popen_safe_legacy(args, write=write, stdout=stdout, stderr=stderr, **kwargs) + else: + p = subprocess.Popen(args, universal_newlines=True, close_fds=False, + stdout=stdout, stderr=stderr, **kwargs) + o, e = p.communicate(write) + # Sometimes the command that we run will call another command which will be + # without the above stdin workaround, so set the console mode again just in + # case. + mlog.setup_console() return p, o, e def Popen_safe_legacy(args: T.List[str], write: T.Optional[str] = None, |