diff options
| author | adrian | 2017-06-01 17:45:07 -0700 | 
|---|---|---|
| committer | adrian | 2017-06-01 17:45:07 -0700 | 
| commit | de78999defacb0dff102635457884730ff059d0b (patch) | |
| tree | c04b161f345ccbaf2afe10399283c27447564448 /Library/Homebrew/utils.rb | |
| parent | 8b26deef20697c3d68fc42987f2513cb1e953c77 (diff) | |
| download | brew-de78999defacb0dff102635457884730ff059d0b.tar.bz2 | |
don't try to find the full path of the editor in 'brew edit'
fixes #2709
Diffstat (limited to 'Library/Homebrew/utils.rb')
| -rw-r--r-- | Library/Homebrew/utils.rb | 32 | 
1 files changed, 15 insertions, 17 deletions
| diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index f837de202..4efcb2b4d 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -262,6 +262,14 @@ ensure    ENV["PATH"] = old_path  end +def with_homebrew_path +  old_path = ENV["PATH"] +  ENV["PATH"] = ENV["HOMEBREW_PATH"] +  yield +ensure +  ENV["PATH"] = old_path +end +  def with_custom_locale(locale)    old_locale = ENV["LC_ALL"]    ENV["LC_ALL"] = locale @@ -321,23 +329,13 @@ end  def which_editor    editor = ENV.values_at("HOMEBREW_EDITOR", "HOMEBREW_VISUAL").compact.reject(&:empty?).first -  if editor -    editor_name, _, editor_args = editor.partition " " -    editor_path = which(editor_name, ENV["HOMEBREW_PATH"]) -    editor = if editor_args.to_s.empty? -      editor_path.to_s -    else -      "#{editor_path} #{editor_args}" -    end -    return editor +  return editor unless editor.nil? + +  # Find Textmate, BBEdit / TextWrangler, or vim +  %w[mate edit vim].each do |candidate| +    editor = candidate if which(candidate, ENV["HOMEBREW_PATH"])    end -  # Find Textmate -  editor = which("mate", ENV["HOMEBREW_PATH"]) -  # Find BBEdit / TextWrangler -  editor ||= which("edit", ENV["HOMEBREW_PATH"]) -  # Find vim -  editor ||= which("vim", ENV["HOMEBREW_PATH"])    # Default to standard vim    editor ||= "/usr/bin/vim" @@ -347,12 +345,12 @@ def which_editor      or HOMEBREW_EDITOR to your preferred text editor.    EOS -  editor.to_s +  editor  end  def exec_editor(*args)    puts "Editing #{args.join "\n"}" -  safe_exec(which_editor, *args) +  with_homebrew_path { safe_exec(which_editor, *args) }  end  def exec_browser(*args) | 
