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
 | 
					#  old-fashioned 'shl' like program
 | 
				
			||||||
#  by A. Ito
 | 
					#  by A. Ito
 | 
				
			||||||
| 
						 | 
					@ -22,15 +23,15 @@ def writer
 | 
				
			||||||
  begin
 | 
					  begin
 | 
				
			||||||
    while true
 | 
					    while true
 | 
				
			||||||
      c = STDIN.getc
 | 
					      c = STDIN.getc
 | 
				
			||||||
      if c == 26 then # C-z
 | 
					      if c == ?\C-z then
 | 
				
			||||||
        $reader.raise(nil)
 | 
					        $reader.raise('Suspend')
 | 
				
			||||||
        return 'Suspend'
 | 
					        return 'Suspend'
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
      $w_pty.print c.chr
 | 
					      $w_pty.print c.chr
 | 
				
			||||||
      $w_pty.flush
 | 
					      $w_pty.flush
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  rescue
 | 
					  rescue
 | 
				
			||||||
    $reader.raise(nil)
 | 
					    $reader.raise('Exit')
 | 
				
			||||||
    return 'Exit'
 | 
					    return 'Exit'
 | 
				
			||||||
  ensure
 | 
					  ensure
 | 
				
			||||||
    system "stty echo -raw"
 | 
					    system "stty echo -raw"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue