Skip to content

Instantly share code, notes, and snippets.

@yaeda
Created January 9, 2013 03:55
Show Gist options
  • Save yaeda/4490414 to your computer and use it in GitHub Desktop.
Save yaeda/4490414 to your computer and use it in GitHub Desktop.
Rubyでecho無しに標準入力させる方法
# < 1.9.3
print "type PASSWORD : "
system "stty -echo"
password = gets.chop
system "stty echo"
# > 1.9.3
require 'io/console'
print "type PASSWORD : "
password = STDIN.noecho(&:gets).chop
@yaeda
Copy link
Author

yaeda commented Jan 9, 2013

chopは改行コードの削除

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment