Ensure consistent tab completes
This commit is contained in:
@@ -1842,7 +1842,6 @@ class Core
|
||||
# @param words [Array<String>] the previously completed words on the command line. words is always
|
||||
# at least 1 when tab completion has reached this stage since the command itself has been completed
|
||||
def cmd_set_tabs(str, words)
|
||||
|
||||
# A value has already been specified
|
||||
return [] if words.length > 2
|
||||
|
||||
@@ -1850,8 +1849,7 @@ class Core
|
||||
if words.length == 2
|
||||
return tab_complete_option_values(str, words, opt: words[1])
|
||||
end
|
||||
Readline.completion_append_character = " "
|
||||
return tab_complete_option_names(str, words)
|
||||
tab_complete_option_names(str, words)
|
||||
end
|
||||
|
||||
def cmd_setg_help
|
||||
|
||||
@@ -33,19 +33,21 @@ module Msf
|
||||
def tab_complete_option(str, words)
|
||||
if str.end_with?('=')
|
||||
option_name = str.chop
|
||||
option_value = ''
|
||||
|
||||
::Readline.completion_append_character = ' '
|
||||
return tab_complete_option_values(option_name, words, opt: option_name).map { |value| "#{str}#{value}" }
|
||||
else
|
||||
if str.include?('=')
|
||||
str_split = str.split('=')
|
||||
option_value = str_split[1].strip
|
||||
option_name = str_split[0].strip
|
||||
::Readline.completion_append_character = ' '
|
||||
return tab_complete_option_values(option_value, words, opt: option_name).map { |value| "#{option_name}=#{value}" }
|
||||
end
|
||||
return tab_complete_option_values(option_value, words, opt: option_name).map { |value| "#{str}#{value}" }
|
||||
elsif str.include?('=')
|
||||
str_split = str.split('=')
|
||||
option_name = str_split[0].strip
|
||||
option_value = str_split[1].strip
|
||||
|
||||
::Readline.completion_append_character = ' '
|
||||
return tab_complete_option_values(option_value, words, opt: option_name).map { |value| "#{option_name}=#{value}" }
|
||||
end
|
||||
::Readline.completion_append_character = ' '
|
||||
return tab_complete_option_names(str, words).map { |name| "#{name}=" }
|
||||
|
||||
::Readline.completion_append_character = ''
|
||||
tab_complete_option_names(str, words).map { |name| "#{name}=" }
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
@@ -358,6 +358,8 @@ module DispatcherShell
|
||||
# Readline.basic_word_break_characters variable being set to \x00
|
||||
#
|
||||
def tab_complete(str)
|
||||
::Readline.completion_append_character = ' '
|
||||
|
||||
# Check trailing whitespace so we can tell 'x' from 'x '
|
||||
str_match = str.match(/[^\\]([\\]{2})*\s+$/)
|
||||
str_trail = (str_match.nil?) ? '' : str_match[0]
|
||||
|
||||
Reference in New Issue
Block a user