diff options
| author | Mike McQuaid | 2017-04-22 12:41:42 +0100 |
|---|---|---|
| committer | GitHub | 2017-04-22 12:41:42 +0100 |
| commit | 268f2dbde2f157bab14518a2d725a111a44e00a3 (patch) | |
| tree | 1658f3b7d0cd57919b35dffee94ff4c40da74877 /Library/Homebrew | |
| parent | 44232ab0446f25d0a59ef085870fc620a6337068 (diff) | |
| parent | 69c7a20896813aefa519aaee7b75552731cd672a (diff) | |
| download | brew-268f2dbde2f157bab14518a2d725a111a44e00a3.tar.bz2 | |
Merge pull request #2476 from MikeMcQuaid/edit-env-filtering
Fix `brew edit` with environment filtering.
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/test/utils_spec.rb | 8 | ||||
| -rw-r--r-- | Library/Homebrew/utils.rb | 6 |
2 files changed, 10 insertions, 4 deletions
diff --git a/Library/Homebrew/test/utils_spec.rb b/Library/Homebrew/test/utils_spec.rb index 314c299a8..dd7ea20de 100644 --- a/Library/Homebrew/test/utils_spec.rb +++ b/Library/Homebrew/test/utils_spec.rb @@ -189,7 +189,13 @@ describe "globally-scoped helper methods" do specify "#which_editor" do ENV["HOMEBREW_EDITOR"] = "vemate" - expect(which_editor).to eq("vemate") + ENV["HOMEBREW_PATH"] = dir + + editor = dir/"vemate" + FileUtils.touch editor + FileUtils.chmod 0755, editor + + expect(which_editor).to eql editor end specify "#gzip" do 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 |
