Skip to content

Commit 0ad7d10

Browse files
committed
Use a continuation flag to disable tab completion
1 parent 6d7579d commit 0ad7d10

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/rex/ui/text/shell.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def initialize(prompt, prompt_char = '>', histfile = nil, framework = nil)
4747
# Initialize the prompt
4848
self.init_prompt = prompt
4949
self.cont_prompt = ' > '
50+
self.cont_flag = false
5051
self.prompt_char = prompt_char
5152

5253
self.histfile = histfile
@@ -57,7 +58,8 @@ def initialize(prompt, prompt_char = '>', histfile = nil, framework = nil)
5758

5859
def init_tab_complete
5960
if (self.input and self.input.supports_readline)
60-
self.input = Input::Readline.new(lambda { |str| tab_complete(str) })
61+
# Unless cont_flag because there's no tab complete for continuation lines
62+
self.input = Input::Readline.new(lambda { |str| tab_complete(str) unless cont_flag })
6163
if Readline::HISTORY.length == 0 and histfile and File.exist?(histfile)
6264
File.readlines(histfile).each { |e|
6365
Readline::HISTORY << e.chomp
@@ -355,13 +357,15 @@ def get_input_line
355357
line = "\\\n"
356358
prompt_needs_reset = false
357359

360+
self.cont_flag = false
358361
while line =~ /(^|[^\\])\\\s*$/
359362
# Strip \ and all the trailing whitespace
360363
line.sub!(/\\\s*/, '')
361364

362365
if line.length > 0
363366
# Using update_prompt will overwrite the primary prompt
364367
input.prompt = output.update_prompt(self.cont_prompt)
368+
self.cont_flag = true
365369
prompt_needs_reset = true
366370
end
367371

@@ -370,6 +374,7 @@ def get_input_line
370374
output.input = nil
371375
log_output(input.prompt)
372376
end
377+
self.cont_flag = false
373378

374379
if prompt_needs_reset
375380
# The continuation prompt was used so reset the prompt
@@ -424,6 +429,11 @@ def log_output(buf)
424429
attr_accessor :histfile # :nodoc:
425430
attr_accessor :hist_last_saved # the number of history lines when last saved/loaded
426431
attr_accessor :log_source, :stop_count # :nodoc:
432+
attr_reader :cont_flag # :nodoc:
433+
434+
private
435+
436+
attr_writer :cont_flag # :nodoc:
427437

428438
end
429439

0 commit comments

Comments
 (0)