shell_read_until_token should work for any requested idx now
git-svn-id: file:///home/svn/framework3/trunk@8665 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
304a238d3e
commit
5ab32ab792
|
@ -132,16 +132,21 @@ class CommandShell
|
||||||
if (not (select([rstream], nil, nil, 5)))
|
if (not (select([rstream], nil, nil, 5)))
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
if (wanted_idx == 0)
|
||||||
|
parts_needed = 2
|
||||||
|
else
|
||||||
|
parts_needed = 1 + (wanted_idx * 2)
|
||||||
|
end
|
||||||
|
|
||||||
# Read until we get the token or timeout.
|
# Read until we get the token or timeout.
|
||||||
buf = ''
|
buf = ''
|
||||||
idx = nil
|
idx = nil
|
||||||
while (tmp = rstream.get_once(-1, 1))
|
while (tmp = rstream.get_once(-1, 1))
|
||||||
buf << tmp
|
buf << tmp
|
||||||
|
|
||||||
# see if we have the wanted idx
|
# see if we have the wanted idx
|
||||||
parts = buf.split(token, -1)
|
parts = buf.split(token, -1)
|
||||||
if (parts.length == 1+(wanted_idx*2))
|
if (parts.length == parts_needed)
|
||||||
# cause another prompt to appear (just in case)
|
# cause another prompt to appear (just in case)
|
||||||
shell_write("\n")
|
shell_write("\n")
|
||||||
return parts[wanted_idx]
|
return parts[wanted_idx]
|
||||||
|
|
Loading…
Reference in New Issue