File tree Expand file tree Collapse file tree 1 file changed +22
-16
lines changed
lib/msf/ui/console/command_dispatcher Expand file tree Collapse file tree 1 file changed +22
-16
lines changed Original file line number Diff line number Diff line change @@ -77,32 +77,38 @@ def cmd_edit_help
77
77
# Edit the currently active module or a local file
78
78
#
79
79
def cmd_edit ( *args )
80
+ editing_module = false
81
+
80
82
if args . length > 0
81
83
path = args [ 0 ]
82
84
elsif active_module
85
+ editing_module = true
83
86
path = active_module . file_path
84
87
end
85
88
86
- if path
87
- editor = local_editor
89
+ if path . nil?
90
+ print_error ( 'Nothing to edit. Try using a module first or specifying a library file to edit.' )
91
+ return
92
+ end
88
93
89
- if editor . nil?
90
- editor = 'vim'
91
- print_warning ( "LocalEditor or $VISUAL/$EDITOR should be set. Falling back on #{ editor } ." )
92
- end
94
+ editor = local_editor
93
95
94
- print_status ( "Launching #{ editor } #{ path } " )
95
- system ( *editor . split , path )
96
+ if editor . nil?
97
+ editor = 'vim'
98
+ print_warning ( "LocalEditor or $VISUAL/$EDITOR should be set. Falling back on #{ editor } ." )
99
+ end
96
100
97
- # XXX: This will try to reload *any* .rb and break on modules
98
- if args . length > 0 && path . end_with? ( '.rb' )
99
- print_status ( "Reloading #{ path } " )
100
- load path
101
- else
102
- print_error ( 'Only Ruby files can be reloaded (use reload/rerun for modules)' )
103
- end
101
+ print_status ( "Launching #{ editor } #{ path } " )
102
+ system ( *editor . split , path )
103
+
104
+ return if editing_module
105
+
106
+ # XXX: This will try to reload *any* .rb and break on modules
107
+ if path . end_with? ( '.rb' )
108
+ print_status ( "Reloading #{ path } " )
109
+ load path
104
110
else
105
- print_error ( 'Nothing to edit -- try using a module first .' )
111
+ print_error ( 'Only library files can be reloaded after editing .' )
106
112
end
107
113
end
108
114
You can’t perform that action at this time.
0 commit comments