mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
69b6471104
commit
b163b3ff64
1 changed files with 6 additions and 8 deletions
|
@ -14,7 +14,6 @@ require 'pty'
|
||||||
require 'io/console'
|
require 'io/console'
|
||||||
|
|
||||||
$shells = []
|
$shells = []
|
||||||
$n_shells = 0
|
|
||||||
|
|
||||||
$r_pty = nil
|
$r_pty = nil
|
||||||
$w_pty = nil
|
$w_pty = nil
|
||||||
|
@ -64,17 +63,15 @@ while true
|
||||||
STDOUT.flush
|
STDOUT.flush
|
||||||
case gets
|
case gets
|
||||||
when /^c/i
|
when /^c/i
|
||||||
$shells[$n_shells] = PTY.spawn("/bin/csh")
|
$shells << PTY.spawn("/bin/csh")
|
||||||
$r_pty,$w_pty = $shells[$n_shells]
|
$r_pty,$w_pty = $shells[-1]
|
||||||
$n_shells += 1
|
|
||||||
$reader.run
|
$reader.run
|
||||||
if writer == 'Exit'
|
if writer == 'Exit'
|
||||||
$n_shells -= 1
|
$shells.pop
|
||||||
$shells[$n_shells] = nil
|
|
||||||
end
|
end
|
||||||
when /^p/i
|
when /^p/i
|
||||||
for i in 0..$n_shells
|
$shells.each_with_index do |s, i|
|
||||||
unless $shells[i].nil?
|
if s
|
||||||
print i,"\n"
|
print i,"\n"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -87,6 +84,7 @@ while true
|
||||||
$reader.run
|
$reader.run
|
||||||
if writer == 'Exit' then
|
if writer == 'Exit' then
|
||||||
$shells[n] = nil
|
$shells[n] = nil
|
||||||
|
$shells.pop until $shells.empty? or $shells[-1]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
when /^q/i
|
when /^q/i
|
||||||
|
|
Loading…
Reference in a new issue