Skip to content

Commit f45b0e3

Browse files
committed
Land rapid7#7643, only use ANSI ctrl chars in stdio output
2 parents 76db530 + c9b5e43 commit f45b0e3

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

lib/rex/ui/text/output.rb

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,7 @@ def print_status(msg = '')
6363
end
6464

6565
def print_line(msg = '')
66-
if (/mingw/ =~ RUBY_PLATFORM)
67-
print(msg + "\n")
68-
return
69-
end
70-
print("\033[s") # Save cursor position
71-
print("\r\033[K" + msg + "\n")
72-
if input and input.prompt
73-
print("\r\033[K")
74-
print(input.prompt.tr("\001\002", ''))
75-
print(input.line_buffer.tr("\001\002", ''))
76-
print("\033[u\033[B") # Restore cursor, move down one line
77-
end
66+
print(msg + "\n")
7867
end
7968

8069
def print_warning(msg = '')

lib/rex/ui/text/output/stdio.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,23 @@ def io
5555
@io ||= $stdout
5656
end
5757

58+
# Use ANSI Control chars to reset prompt position for async output
59+
# SEE https://github.com/rapid7/metasploit-framework/pull/7570
60+
def print_line(msg = '')
61+
if (/mingw/ =~ RUBY_PLATFORM)
62+
print(msg + "\n")
63+
return
64+
end
65+
print("\033[s") # Save cursor position
66+
print("\r\033[K" + msg + "\n")
67+
if input and input.prompt
68+
print("\r\033[K")
69+
print(input.prompt.tr("\001\002", ''))
70+
print(input.line_buffer.tr("\001\002", ''))
71+
print("\033[u\033[B") # Restore cursor, move down one line
72+
end
73+
end
74+
5875
#
5976
# Prints the supplied message to standard output.
6077
#

0 commit comments

Comments
 (0)