Skip to content

Commit

Permalink
Remove unused param and only set tty when we can (#5310)
Browse files Browse the repository at this point in the history
* Remove unused param and only set tty when we can

Fixes a Drupal 10 test failure "TTY mode requires /dev/tty to be read/writable."

* Adjust test

* Allow user option tty

* Remove code comment
  • Loading branch information
weitzman authored Nov 11, 2022
1 parent 6e34af4 commit 7833d00
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/Commands/core/SshCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Drush\Commands\core;

use Consolidation\SiteProcess\Util\Shell;
use Consolidation\SiteProcess\Util\Tty;
use Drush\Commands\DrushCommands;
use Consolidation\SiteAlias\SiteAliasManagerAwareInterface;
use Consolidation\SiteAlias\SiteAliasManagerAwareTrait;
Expand Down Expand Up @@ -31,7 +32,7 @@ class SshCommands extends DrushCommands implements SiteAliasManagerAwareInterfac
* @aliases ssh,site-ssh
* @topics docs:aliases
*/
public function ssh(array $code, $options = ['cd' => self::REQ, 'tty' => false]): void
public function ssh(array $code, $options = ['cd' => self::REQ]): void
{
$alias = $this->siteAliasManager()->getSelf();

Expand All @@ -49,7 +50,9 @@ public function ssh(array $code, $options = ['cd' => self::REQ, 'tty' => false])
}

$process = $this->processManager()->siteProcess($alias, $code);
$process->setTty($options['tty']);
if (Tty::isTtySupported()) {
$process->setTty($options['tty']);
}
// The transport handles the chdir during processArgs().
$fallback = $alias->hasRoot() ? $alias->root() : null;
$process->setWorkingDirectory($options['cd'] ?: $fallback);
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/SiteSshTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function testInteractive()
];
$this->drush('ssh', [], $options, 'user@server/path/to/drupal#sitename');
$output = $this->getErrorOutput();
$expected = "[notice] Simulating: ssh -t -o PasswordAuthentication=no user@server 'cd /path/to/drupal && bash -l'";
$expected = "[notice] Simulating: ssh -o PasswordAuthentication=no user@server 'cd /path/to/drupal && bash -l'";
$this->assertStringContainsString($expected, $output);
}

Expand Down

0 comments on commit 7833d00

Please sign in to comment.