Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In SSH, only send TERM env by default if it is a supported value #1496

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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