prompt_for_password: remove external bash dependency
This commit is contained in:
parent
fb67ffdf3b
commit
99c350267f
1 changed files with 5 additions and 11 deletions
14
src/Cli.php
14
src/Cli.php
|
@ -412,16 +412,10 @@ Additional parameters:
|
|||
* @return string
|
||||
*/
|
||||
public static function prompt_for_password($prompt=null) {
|
||||
// Check bash is available
|
||||
$command = "/usr/bin/env bash -c 'echo OK'";
|
||||
if (rtrim(shell_exec($command)) !== 'OK')
|
||||
Log::fatal(I18n::_("Can't invoke bash. Can't ask password prompt."));
|
||||
|
||||
$command = "/usr/bin/env bash -c 'read -s -p \"";
|
||||
$command .= addslashes($prompt?_($prompt):I18n::_("Please enter password:"));
|
||||
$command .= "\" mypassword && echo \$mypassword'";
|
||||
$password = rtrim(shell_exec($command));
|
||||
echo "\n";
|
||||
print($prompt?_($prompt):I18n::_("Please enter password:"));
|
||||
system('stty -echo');
|
||||
$password = trim(fgets(STDIN));
|
||||
system('stty echo');
|
||||
return $password;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue