public function decorateCommand($command, CommandExecutor $executor) { $command = $this->parent ? $this->parent->decorateCommand($command, $executor) : $command; if ($this->onlyForCommands) { list($arg) = explode(' ', $command); if (false === in_array($arg, $this->onlyForCommands)) { return $command; } } return 'sudo -- ' . $command; }
public function decorateCommand($command, CommandExecutor $executor) { $command = $this->parent ? $this->parent->decorateCommand($command, $executor) : $command; $sshCommand = 'ssh -A'; if ($executor->getTty()) { $sshCommand .= ' -t'; } if ($this->getVerbose()) { $sshCommand .= ' -v'; } if ($this->getPort()) { $sshCommand .= ' -p ' . $this->getPort(); } if ($this->getIdentityFile()) { $sshCommand .= ' -i ' . escapeshellarg($this->getIdentityFile()); } if ($this->getUser()) { $target = escapeshellarg($this->getUser() . '@' . $this->getHost()); } else { $target = escapeshellarg($this->getHost()); } return sprintf("%s %s %s", $sshCommand, $target, escapeshellarg($command)); }