mitchellh/vagrant — pull request #4408 by lsimons (2014-08-28 16:11:07+00:00)
Title: Scrub SSH PTY output to filter out command echo-ing and most other cruft

Following up on issue #4404, here is a more conservative patch that does seem to work pretty reliably, to allow most built-in vagrant commands to work when `config.ssh.pty = true`.

Should solve #4221, #3939, #3571, #3106, #3063 and others.

The line
```ruby
raise Vagrant::Errors::SSHInvalidShell.new
```
should raise a dedicated exception, I guess, but I couldn't quite figure out how all the i18n stuff works, sorry.

The line
```ruby
sleep(0.1)
```
is quite unfortunate, but without it, due to the async nature of Net::SSH, there is a bit of a timing issue where sometimes the new terminal settings have not been applied before the printf of the delimiters happens. 0.1 should be enough time for almost all terminals and almost all SSH connections.

The line
```ruby
use_tty = success and command != ''
```
has that "and command != ''" trick in it because vagrant seems to like sending a lot of empty commands to check that the connection is available, and I don't want to slow all those empty checks down.