Make sure no error is output if env is missing
parent
c28f3aa5c5
commit
fc8d92e7a2
|
@ -162,22 +162,24 @@ class ConsoleIO implements IOInterface
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle other OSs with bash/zsh/ksh/csh if available to hide the answer
|
if (file_exists('/usr/bin/env')) {
|
||||||
$test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null";
|
// handle other OSs with bash/zsh/ksh/csh if available to hide the answer
|
||||||
foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) {
|
$test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null";
|
||||||
if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) {
|
foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) {
|
||||||
$shell = $sh;
|
if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) {
|
||||||
break;
|
$shell = $sh;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if (isset($shell)) {
|
||||||
if (isset($shell)) {
|
$this->write($question, false);
|
||||||
$this->write($question, false);
|
$readCmd = ($shell === 'csh') ? 'set mypassword = $<' : 'read mypassword';
|
||||||
$readCmd = ($shell === 'csh') ? 'set mypassword = $<' : 'read mypassword';
|
$command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd);
|
||||||
$command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd);
|
$value = rtrim(shell_exec($command));
|
||||||
$value = rtrim(shell_exec($command));
|
$this->write('');
|
||||||
$this->write('');
|
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// not able to hide the answer, proceed with normal question handling
|
// not able to hide the answer, proceed with normal question handling
|
||||||
|
|
Loading…
Reference in New Issue