module Net::SSH::PromptMethods::Termios
Defines the prompt method to use if the Termios library is installed.
Public Instance Methods
prompt(prompt, echo=true)
click to toggle source
Displays the prompt to $stdout. If echo
is false, the Termios library will be used to disable keystroke
echoing for the duration of this method.
# File lib/net/ssh/prompt.rb, line 27 def prompt(prompt, echo=true) $stdout.print(prompt) $stdout.flush set_echo(false) unless echo $stdin.gets.chomp ensure if !echo set_echo(true) $stdout.puts end end
Private Instance Methods
set_echo(enable)
click to toggle source
Enables or disables keystroke echoing using the Termios library.
# File lib/net/ssh/prompt.rb, line 43 def set_echo(enable) term = ::Termios.getattr($stdin) if enable term.c_lflag |= (::Termios::ECHO | ::Termios::ICANON) else term.c_lflag &= ~::Termios::ECHO end ::Termios.setattr($stdin, ::Termios::TCSANOW, term) end