protected function getHiddenResponse($inputStream)
{
if ('\\' === DIRECTORY_SEPARATOR) {
$exe = __DIR__ . '/../bin/hiddeninput.exe';
$value = rtrim(shell_exec($exe));
$this->output->writeln('');
if (isset($tmpExe)) {
unlink($tmpExe);
}
return $value;
}
if ($this->hasSttyAvailable()) {
$sttyMode = shell_exec('stty -g');
shell_exec('stty -echo');
$value = fgets($inputStream, 4096);
shell_exec(sprintf('stty %s', $sttyMode));
if (false === $value) {
throw new \RuntimeException('Aborted');
}
$value = trim($value);
$this->output->writeln('');
return $value;
}
if (false !== ($shell = $this->getShell())) {
$readCmd = $shell === 'csh' ? 'set mypassword = $<' : 'read -r mypassword';
$command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd);
$value = rtrim(shell_exec($command));
$this->output->writeln('');
return $value;
}
throw new \RuntimeException('Unable to hide the response.');
}