diff options
| author | Mike McQuaid | 2017-04-19 10:49:20 +0100 | 
|---|---|---|
| committer | Mike McQuaid | 2017-04-21 18:26:12 +0100 | 
| commit | 69c7a20896813aefa519aaee7b75552731cd672a (patch) | |
| tree | 9319951323da7886af60a22534061c489436f3ff /Library/Homebrew/utils.rb | |
| parent | 6e1faf5b8837e228785dde0cfd8ca47336fb5494 (diff) | |
| download | brew-69c7a20896813aefa519aaee7b75552731cd672a.tar.bz2 | |
Fix `brew edit` with environment filtering.
For many people `brew edit` makes use of the `EDITOR` variable to pick a
sensible editor. With environment filtering enabled unless this editor
is found in the default system PATH it'll fall back to e.g. `vim`.
Instead, ensure that we export the original, pre-filtering `PATH` as
`HOMEBREW_PATH` and use that internally to locate the editor. In future
this same approach will likely be used for requirements to be able to
find tools, too, and for other variables which we want to expose to
Homebrew itself but not other build tools.
Note that `HOMEBREW_PATH` is the same as `PATH` when build filtering
hasn't been enabled.
Diffstat (limited to 'Library/Homebrew/utils.rb')
| -rw-r--r-- | Library/Homebrew/utils.rb | 6 | 
1 files changed, 3 insertions, 3 deletions
| diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 46a8cc68e..7a14916e1 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -320,8 +320,8 @@ def which_all(cmd, path = ENV["PATH"])  end  def which_editor -  editor = ENV.values_at("HOMEBREW_EDITOR", "VISUAL", "EDITOR").compact.first -  return editor unless editor.nil? +  editor = ENV.values_at("HOMEBREW_EDITOR", "VISUAL").compact.first +  return which(editor, ENV["HOMEBREW_PATH"]) unless editor.nil?    # Find Textmate    editor = "mate" if which "mate" @@ -334,7 +334,7 @@ def which_editor    opoo <<-EOS.undent      Using #{editor} because no editor was set in the environment. -    This may change in the future, so we recommend setting EDITOR, VISUAL, +    This may change in the future, so we recommend setting EDITOR,      or HOMEBREW_EDITOR to your preferred text editor.    EOS | 
