summaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-12-05 17:12:21 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2022-12-05 19:23:16 +0900
commit0b767d743f38b660e25a3a6df97598ba65bd0620 (patch)
tree30a0a23bb1bb1ff263a8e1ff50a5d542523342b4 /sample
parentfaee3b90392c8f5a5ddfd0bba36d35cbb7b7d199 (diff)
downloadruby-0b767d743f38b660e25a3a6df97598ba65bd0620.tar.gz
Use io/console to avoid stty error [ci skip]
Diffstat (limited to 'sample')
-rwxr-xr-xsample/mine.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/sample/mine.rb b/sample/mine.rb
index a841d1a60a..77e0204bf6 100755
--- a/sample/mine.rb
+++ b/sample/mine.rb
@@ -1,6 +1,8 @@
#! /usr/bin/ruby -Ku
# -*- coding: utf-8 -*-
+require 'io/console'
+
class Board
def clr
print "\e[2J"
@@ -143,8 +145,8 @@ class Board
end
bd=Board.new(10,10,10)
-system("stty raw -echo")
-begin
+
+IO.console.raw do
loop do
case STDIN.getc
when ?n # new game
@@ -170,7 +172,5 @@ begin
bd.reset
end
end
-ensure
- system("stty -raw echo")
end
print "\n"