mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
sample/pty/shl.rb: update sample
* Specify frozen_string_literal: true. * Fix TypeError of raise. * Use a character literal instead of Integer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
af2009a58f
commit
5b540799bf
1 changed files with 4 additions and 3 deletions
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
#
|
||||
# old-fashioned 'shl' like program
|
||||
# by A. Ito
|
||||
|
@ -22,15 +23,15 @@ def writer
|
|||
begin
|
||||
while true
|
||||
c = STDIN.getc
|
||||
if c == 26 then # C-z
|
||||
$reader.raise(nil)
|
||||
if c == ?\C-z then
|
||||
$reader.raise('Suspend')
|
||||
return 'Suspend'
|
||||
end
|
||||
$w_pty.print c.chr
|
||||
$w_pty.flush
|
||||
end
|
||||
rescue
|
||||
$reader.raise(nil)
|
||||
$reader.raise('Exit')
|
||||
return 'Exit'
|
||||
ensure
|
||||
system "stty echo -raw"
|
||||
|
|
Loading…
Add table
Reference in a new issue