Skip to content

Commit

Permalink
Land rapid7#7739, async output revert until fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
wvu committed Dec 21, 2016
2 parents 0221d2d + 4098c66 commit 445af29
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
21 changes: 16 additions & 5 deletions lib/rex/ui/text/input/readline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,27 @@ def intrinsic_shell?
private

def readline_with_output(prompt, add_history=false)
# rb-readlines's Readline.readline hardcodes the input and output to $stdin and $stdout, which means setting
# `Readline.input` or `Readline.ouput` has no effect when running `Readline.readline` with rb-readline, so need
# to reimplement []`Readline.readline`](https://github.com/luislavena/rb-readline/blob/ce4908dae45dbcae90a6e42e3710b8c3a1f2cd64/lib/readline.rb#L36-L58)
# for rb-readline to support setting input and output. Output needs to be set so that colorization works for the
# prompt on Windows.
# rb-readlines's Readline.readline hardcodes the input and output to
# $stdin and $stdout, which means setting `Readline.input` or
# `Readline.ouput` has no effect when running `Readline.readline` with
# rb-readline, so need to reimplement
# []`Readline.readline`](https://github.com/luislavena/rb-readline/blob/ce4908dae45dbcae90a6e42e3710b8c3a1f2cd64/lib/readline.rb#L36-L58)
# for rb-readline to support setting input and output. Output needs to
# be set so that colorization works for the prompt on Windows.
self.prompt = prompt

# TODO: there are unhandled quirks in async output buffering that
# we have not solved yet, for instance when loading meterpreter
# extensions, supporting Windows, printing output from commands, etc.
# Remove this guard when issues are resolved.
=begin
reset_sequence = "\n\001\r\033[K\002"
if (/mingw/ =~ RUBY_PLATFORM)
reset_sequence = ""
end
=end
reset_sequence = ""

if defined? RbReadline
RbReadline.rl_instream = fd
RbReadline.rl_outstream = output
Expand Down
8 changes: 8 additions & 0 deletions lib/rex/ui/text/output/stdio.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ def io
# Use ANSI Control chars to reset prompt position for async output
# SEE https://github.com/rapid7/metasploit-framework/pull/7570
def print_line(msg = '')
# TODO: there are unhandled quirks in async output buffering that
# we have not solved yet, for instance when loading meterpreter
# extensions, supporting Windows, printing output from commands, etc.
# Remove this guard when issues are resolved.
=begin
if (/mingw/ =~ RUBY_PLATFORM)
print(msg + "\n")
return
Expand All @@ -70,6 +75,9 @@ def print_line(msg = '')
print(input.line_buffer.tr("\001\002", ''))
print("\033[u\033[B") # Restore cursor, move down one line
end
=end

print(msg + "\n")
end

#
Expand Down

0 comments on commit 445af29

Please sign in to comment.