Skip to content

Commit 3263f82

Browse files
committed
In SSH, only send TERM env by default if it is a supported value
1 parent f45a53e commit 3263f82

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/Command/Environment/EnvironmentSshCommand.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,19 @@ protected function execute(InputInterface $input, OutputInterface $output)
9090
throw new InvalidArgumentException('The cmd argument is required when running via "multi"');
9191
}
9292

93+
$options = $input->getOption('option');
94+
95+
// Send the TERM environment variable by default, when it has a
96+
// supported value and when opening a shell (i.e. when no command is
97+
// specified).
98+
$validTermInfo = ['xterm', 'xterm-color', 'xterm-16color', 'xterm-256color'];
99+
if (empty($remoteCommand) && in_array(getenv('TERM'), $validTermInfo, true)) {
100+
$options = array_merge(['SendEnv TERM'], $options);
101+
}
102+
93103
/** @var \Platformsh\Cli\Service\Ssh $ssh */
94104
$ssh = $this->getService('ssh');
95-
$command = $ssh->getSshCommand($sshUrl, $input->getOption('option'), $remoteCommand);
105+
$command = $ssh->getSshCommand($sshUrl, $options, $remoteCommand);
96106

97107
/** @var \Platformsh\Cli\Service\Shell $shell */
98108
$shell = $this->getService('shell');

src/Service/Ssh.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ private function getSshOptions($hostIsInternal)
9999
{
100100
$options = [];
101101

102-
$options[] = 'SendEnv TERM';
103-
104102
if ($this->output->isDebug()) {
105103
if ($this->config->get('api.debug')) {
106104
$options[] = 'LogLevel DEBUG3';

0 commit comments

Comments
 (0)