From df71defdea1c7261cc6b410cec6155e502b5faac Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Thu, 18 Jan 2018 05:55:51 -0600 Subject: [PATCH] fix library-specific error messages to not appear with modules --- lib/msf/ui/console/command_dispatcher/modules.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/msf/ui/console/command_dispatcher/modules.rb b/lib/msf/ui/console/command_dispatcher/modules.rb index a449e21e09..b1a39cc66d 100644 --- a/lib/msf/ui/console/command_dispatcher/modules.rb +++ b/lib/msf/ui/console/command_dispatcher/modules.rb @@ -77,9 +77,11 @@ module Msf # Edit the currently active module or a local file # def cmd_edit(*args) + editing_module = false if args.length > 0 path = args[0] elsif active_module + editing_module = true path = active_module.file_path end @@ -95,14 +97,16 @@ module Msf system(*editor.split, path) # XXX: This will try to reload *any* .rb and break on modules - if args.length > 0 && path.end_with?('.rb') - print_status("Reloading #{path}") - load path - else - print_error('Only Ruby files can be reloaded (use reload/rerun for modules)') + if !editing_module + if path.end_with?('.rb') + print_status("Reloading #{path}") + load path + else + print_error("Only library files can be reloaded after editing (use reload/rerun for modules)") + end end else - print_error('Nothing to edit -- try using a module first.') + print_error('Nothing to edit -- try using a module first, or specifying a library file to edit.') end end