From 51dcf0b836bf87f76b21bc35321e828d564bbdba Mon Sep 17 00:00:00 2001 From: Patrick Dawkins Date: Wed, 23 Oct 2024 13:42:43 +0100 Subject: [PATCH] In SSH, only send TERM env by default if it is a supported value --- src/Command/Environment/EnvironmentSshCommand.php | 12 +++++++++++- src/Service/Ssh.php | 2 -- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Command/Environment/EnvironmentSshCommand.php b/src/Command/Environment/EnvironmentSshCommand.php index cfe5b6d27..f139a106d 100644 --- a/src/Command/Environment/EnvironmentSshCommand.php +++ b/src/Command/Environment/EnvironmentSshCommand.php @@ -90,9 +90,19 @@ protected function execute(InputInterface $input, OutputInterface $output) throw new InvalidArgumentException('The cmd argument is required when running via "multi"'); } + $options = $input->getOption('option'); + + // Send the TERM environment variable by default, when it has a + // supported value and when opening a shell (i.e. when no command is + // specified). + $validTermInfo = ['xterm', 'xterm-color', 'xterm-256color']; + if (empty($remoteCommand) && in_array(getenv('TERM'), $validTermInfo, true)) { + $options = array_merge(['SendEnv TERM'], $options); + } + /** @var \Platformsh\Cli\Service\Ssh $ssh */ $ssh = $this->getService('ssh'); - $command = $ssh->getSshCommand($sshUrl, $input->getOption('option'), $remoteCommand); + $command = $ssh->getSshCommand($sshUrl, $options, $remoteCommand); /** @var \Platformsh\Cli\Service\Shell $shell */ $shell = $this->getService('shell'); diff --git a/src/Service/Ssh.php b/src/Service/Ssh.php index ffe21cf3b..84edf7832 100644 --- a/src/Service/Ssh.php +++ b/src/Service/Ssh.php @@ -99,8 +99,6 @@ private function getSshOptions($hostIsInternal) { $options = []; - $options[] = 'SendEnv TERM'; - if ($this->output->isDebug()) { if ($this->config->get('api.debug')) { $options[] = 'LogLevel DEBUG3';