From d70665e7d6fd618a7b66ae09801514d97abb60e7 Mon Sep 17 00:00:00 2001 From: Bryan Roe Date: Tue, 10 Aug 2021 15:00:12 -0700 Subject: [PATCH] Fixed bug where child process does not set TERM env variable if env block is passed to child. --- agents/meshcore.js | 15 +++++++++++++++ agents/recoverycore.js | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/agents/meshcore.js b/agents/meshcore.js index 974599fb..afc00158 100644 --- a/agents/meshcore.js +++ b/agents/meshcore.js @@ -94,6 +94,21 @@ if (process.platform == 'win32' && require('user-sessions').isRoot()) { } catch (e) { } } +if (process.platform != 'win32') +{ + var ch = require('child_process'); + ch._execFile = ch.execFile; + ch.execFile = function execFile(path, args, options) + { + if(options && options.type && options.type == ch.SpawnTypes.TERM && options.env) + { + options.env['TERM'] = 'xterm-256color'; + } + return (this._execFile(path, args, options)); + }; +} + + if (process.platform == 'darwin' && !process.versions) { // This is an older MacOS Agent, so we'll need to check the service definition so that Auto-Update will function correctly var child = require('child_process').execFile('/bin/sh', ['sh']); diff --git a/agents/recoverycore.js b/agents/recoverycore.js index eda0d297..5ca19756 100644 --- a/agents/recoverycore.js +++ b/agents/recoverycore.js @@ -28,6 +28,20 @@ catch(x) } +if (process.platform != 'win32') +{ + var ch = require('child_process'); + ch._execFile = ch.execFile; + ch.execFile = function execFile(path, args, options) + { + if (options && options.type && options.type == ch.SpawnTypes.TERM && options.env) + { + options.env['TERM'] = 'xterm-256color'; + } + return (this._execFile(path, args, options)); + }; +} + function _getPotentialServiceNames() { var registry = require('win-registry');