diff --git a/CHANGELOG.md b/CHANGELOG.md index b0b78f357..394144d85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ BUG FIXES: - core: Upgrading the home directory for Vagrant 1.5 uses the Vagrant temp dir. [GH-3095] - core: Assume a box isn't metadata if it exceeds 20 MB. [GH-3107] + - core: Asking for input works even in consoles that don't support + hiding input. [GH-3119] - provisioners/ansible: Request SSH info within the provision method, when we know its available. [GH-3111] diff --git a/lib/vagrant/ui.rb b/lib/vagrant/ui.rb index c6dec9078..9e43f0f8b 100644 --- a/lib/vagrant/ui.rb +++ b/lib/vagrant/ui.rb @@ -147,11 +147,19 @@ module Vagrant if opts[:echo] input = $stdin.gets else - input = $stdin.noecho(&:gets) + begin + input = $stdin.noecho(&:gets) - # Output a newline because without echo, the newline isn't - # echoed either. - say(:info, "\n", opts) + # Output a newline because without echo, the newline isn't + # echoed either. + say(:info, "\n", opts) + rescue Errno::EBADF + # This means that stdin doesn't support echoless input. + say(:info, "\n#{I18n.t("vagrant.stdin_cant_hide_input")}\n ", opts) + + # Ask again, with echo enabled + input = ask(message, opts.merge(echo: true)) + end end # Get the results and chomp off the newline. We do a logical OR diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 56c7f5e10..0df34301a 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -166,6 +166,10 @@ en: password-based authentication. Vagrant can't script entering the password for you. If you're prompted for a password, please enter the same password you have configured in the Vagrantfile. + stdin_cant_hide_input: |- + Error! Your console doesn't support hiding input. We'll ask for + input again below, but we WILL NOT be able to hide input. If this + is a problem for you, ctrl-C to exit and fix your stdin. cfengine_config: classes_array: |-