Land #7643, only use ANSI ctrl chars in stdio output

bug/bundler_fix
dmohanty-r7 2016-12-02 12:54:46 -06:00
commit f45b0e3c88
No known key found for this signature in database
GPG Key ID: D1B3982EAB38742F
2 changed files with 18 additions and 12 deletions

View File

@ -63,18 +63,7 @@ class Output < Rex::Ui::Output
end end
def print_line(msg = '') def print_line(msg = '')
if (/mingw/ =~ RUBY_PLATFORM) print(msg + "\n")
print(msg + "\n")
return
end
print("\033[s") # Save cursor position
print("\r\033[K" + msg + "\n")
if input and input.prompt
print("\r\033[K")
print(input.prompt.tr("\001\002", ''))
print(input.line_buffer.tr("\001\002", ''))
print("\033[u\033[B") # Restore cursor, move down one line
end
end end
def print_warning(msg = '') def print_warning(msg = '')

View File

@ -55,6 +55,23 @@ class Output::Stdio < Rex::Ui::Text::Output
@io ||= $stdout @io ||= $stdout
end end
# Use ANSI Control chars to reset prompt position for async output
# SEE https://github.com/rapid7/metasploit-framework/pull/7570
def print_line(msg = '')
if (/mingw/ =~ RUBY_PLATFORM)
print(msg + "\n")
return
end
print("\033[s") # Save cursor position
print("\r\033[K" + msg + "\n")
if input and input.prompt
print("\r\033[K")
print(input.prompt.tr("\001\002", ''))
print(input.line_buffer.tr("\001\002", ''))
print("\033[u\033[B") # Restore cursor, move down one line
end
end
# #
# Prints the supplied message to standard output. # Prints the supplied message to standard output.
# #