Skip to content

Commit

Permalink
In SSH, only send TERM env by default if it is a supported value
Browse files Browse the repository at this point in the history
  • Loading branch information
pjcdawkins committed Oct 23, 2024
1 parent f45a53e commit 51dcf0b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/Command/Environment/EnvironmentSshCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 0 additions & 2 deletions src/Service/Ssh.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 51dcf0b

Please sign in to comment.