Skip to content

Commit 688034d

Browse files
committed
utils: fix which_editor.
Handle when there's no editor variable specified or it's specified but empty.
1 parent 114e8c5 commit 688034d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Library/Homebrew/utils.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,15 +320,15 @@ def which_all(cmd, path = ENV["PATH"])
320320
end
321321

322322
def which_editor
323-
editor = ENV.values_at("HOMEBREW_EDITOR", "VISUAL").compact.first
323+
editor = ENV.values_at("HOMEBREW_EDITOR", "VISUAL").compact.reject(&:empty?).first
324324
return which(editor, ENV["HOMEBREW_PATH"]) unless editor.nil?
325325

326326
# Find Textmate
327-
editor = "mate" if which "mate"
327+
editor = which("mate", ENV["HOMEBREW_PATH"])
328328
# Find BBEdit / TextWrangler
329-
editor ||= "edit" if which "edit"
329+
editor ||= which("edit", ENV["HOMEBREW_PATH"])
330330
# Find vim
331-
editor ||= "vim" if which "vim"
331+
editor ||= which("vim", ENV["HOMEBREW_PATH"])
332332
# Default to standard vim
333333
editor ||= "/usr/bin/vim"
334334

0 commit comments

Comments
 (0)