diff --git a/lib/msf/ui/console/command_dispatcher/core.rb b/lib/msf/ui/console/command_dispatcher/core.rb index ac202c5873..db50e04b2a 100644 --- a/lib/msf/ui/console/command_dispatcher/core.rb +++ b/lib/msf/ui/console/command_dispatcher/core.rb @@ -1842,7 +1842,6 @@ class Core # @param words [Array] 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 diff --git a/lib/msf/ui/console/module_option_tab_completion.rb b/lib/msf/ui/console/module_option_tab_completion.rb index c2b663ec2f..1620d53937 100644 --- a/lib/msf/ui/console/module_option_tab_completion.rb +++ b/lib/msf/ui/console/module_option_tab_completion.rb @@ -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 # diff --git a/lib/rex/ui/text/dispatcher_shell.rb b/lib/rex/ui/text/dispatcher_shell.rb index 20263b35d9..fa421ee5dd 100644 --- a/lib/rex/ui/text/dispatcher_shell.rb +++ b/lib/rex/ui/text/dispatcher_shell.rb @@ -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]