From 69c7a20896813aefa519aaee7b75552731cd672a Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 19 Apr 2017 10:49:20 +0100 Subject: 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. --- Library/Homebrew/test/utils_spec.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'Library/Homebrew/test') 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 -- cgit v1.2.3