summaryrefslogtreecommitdiff
path: root/sample/pty
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-02-04 10:48:15 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-02-04 10:48:15 +0000
commitb163b3ff64638a012998078e7af78b5da69c2ab8 (patch)
tree2479d7e8a39e9087fe78bb1022fc2c7b04092f2f /sample/pty
parent69b647110437dff0b6bf9da2b08ec9a2ae6cf343 (diff)
pty/shl.rb: update [ci skip]
* sample/pty/shl.rb: do not manage array length separately. [ruby-dev:49974] [Bug #13191] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample/pty')
-rw-r--r--sample/pty/shl.rb14
1 files changed, 6 insertions, 8 deletions
diff --git a/sample/pty/shl.rb b/sample/pty/shl.rb
index b5cc55fa83..2360d8dc4c 100644
--- a/sample/pty/shl.rb
+++ b/sample/pty/shl.rb
@@ -14,7 +14,6 @@ require 'pty'
require 'io/console'
$shells = []
-$n_shells = 0
$r_pty = nil
$w_pty = nil
@@ -64,17 +63,15 @@ while true
STDOUT.flush
case gets
when /^c/i
- $shells[$n_shells] = PTY.spawn("/bin/csh")
- $r_pty,$w_pty = $shells[$n_shells]
- $n_shells += 1
+ $shells << PTY.spawn("/bin/csh")
+ $r_pty,$w_pty = $shells[-1]
$reader.run
if writer == 'Exit'
- $n_shells -= 1
- $shells[$n_shells] = nil
+ $shells.pop
end
when /^p/i
- for i in 0..$n_shells
- unless $shells[i].nil?
+ $shells.each_with_index do |s, i|
+ if s
print i,"\n"
end
end
@@ -87,6 +84,7 @@ while true
$reader.run
if writer == 'Exit' then
$shells[n] = nil
+ $shells.pop until $shells.empty? or $shells[-1]
end
end
when /^q/i