def invoke_editor(file, line)
raise CommandError, "Please set Pry.config.editor or export $EDITOR" unless Pry.config.editor
if Pry.config.editor.respond_to?(:call)
editor_invocation = Pry.config.editor.call(file, line)
else
editor_invocation = "#{Pry.config.editor} #{start_line_syntax_for_editor(file, line)}"
end
return nil unless editor_invocation
if jruby?
begin
require 'spoon'
pid = Spoon.spawnp(*editor_invocation.split)
Process.waitpid(pid)
rescue FFI::NotFoundError
system(editor_invocation)
end
else
system(editor_invocation) or raise CommandError, "`#{editor_invocation}` gave exit status: #{$?.exitstatus}"
end
end