Skip to content

Commit 72a0529

Browse files
author
Tod Beardsley
committed
Methodize the editor variable as local_editor
1 parent 6203446 commit 72a0529

File tree

1 file changed

+10
-8
lines changed
  • lib/msf/ui/console/command_dispatcher

1 file changed

+10
-8
lines changed

lib/msf/ui/console/command_dispatcher/core.rb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -628,10 +628,13 @@ def cmd_connect(*args)
628628
true
629629
end
630630

631+
def local_editor
632+
Rex::Compat.getenv('VISUAL') || Rex::Compat.getenv('EDITOR') || '/usr/bin/vim'
633+
end
634+
631635
def cmd_edit_help
632-
editor = Rex::Compat.getenv('VISUAL') || Rex::Compat.getenv('EDITOR')
633636
msg = "Edit the currently active module"
634-
msg = "#{msg} #{editor ? "with #{editor}" : "($EDITOR must be set first)"}."
637+
msg = "#{msg} #{local_editor ? "with #{local_editor}" : "($EDITOR must be set first)"}."
635638
print_line "Usage: edit"
636639
print_line
637640
print_line msg
@@ -643,19 +646,18 @@ def cmd_edit_help
643646
# Edit the currently active module
644647
#
645648
def cmd_edit
646-
editor = ENV['VISUAL'] || ENV['EDITOR']
647-
unless editor
649+
unless local_editor
648650
print_error "$EDITOR must be set first. Try 'export EDITOR=/usr/bin/vim'"
649651
return
650652
end
651-
unless ::File.executable_real? editor
652-
print_error "#{editor} doesn't seem to be executable by you."
653+
unless ::File.executable_real? local_editor
654+
print_error "#{local_editor} doesn't seem to be executable by you."
653655
return
654656
end
655657
if active_module
656658
path = active_module.file_path
657-
print_status "Launching #{editor} #{path}"
658-
system(editor,path)
659+
print_status "Launching #{local_editor} #{path}"
660+
system(local_editor,path)
659661
else
660662
print_error "Nothing to edit -- try using a module first."
661663
end

0 commit comments

Comments
 (0)