Merge pull request #2476 from MikeMcQuaid/edit-env-filtering
Fix `brew edit` with environment filtering.
This commit is contained in:
commit
268f2dbde2
@ -189,7 +189,13 @@ describe "globally-scoped helper methods" do
|
|||||||
|
|
||||||
specify "#which_editor" do
|
specify "#which_editor" do
|
||||||
ENV["HOMEBREW_EDITOR"] = "vemate"
|
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
|
end
|
||||||
|
|
||||||
specify "#gzip" do
|
specify "#gzip" do
|
||||||
|
@ -320,8 +320,8 @@ def which_all(cmd, path = ENV["PATH"])
|
|||||||
end
|
end
|
||||||
|
|
||||||
def which_editor
|
def which_editor
|
||||||
editor = ENV.values_at("HOMEBREW_EDITOR", "VISUAL", "EDITOR").compact.first
|
editor = ENV.values_at("HOMEBREW_EDITOR", "VISUAL").compact.first
|
||||||
return editor unless editor.nil?
|
return which(editor, ENV["HOMEBREW_PATH"]) unless editor.nil?
|
||||||
|
|
||||||
# Find Textmate
|
# Find Textmate
|
||||||
editor = "mate" if which "mate"
|
editor = "mate" if which "mate"
|
||||||
@ -334,7 +334,7 @@ def which_editor
|
|||||||
|
|
||||||
opoo <<-EOS.undent
|
opoo <<-EOS.undent
|
||||||
Using #{editor} because no editor was set in the environment.
|
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.
|
or HOMEBREW_EDITOR to your preferred text editor.
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
|
8
bin/brew
8
bin/brew
@ -44,6 +44,14 @@ fi
|
|||||||
|
|
||||||
HOMEBREW_LIBRARY="$HOMEBREW_REPOSITORY/Library"
|
HOMEBREW_LIBRARY="$HOMEBREW_REPOSITORY/Library"
|
||||||
|
|
||||||
|
for VAR in EDITOR PATH
|
||||||
|
do
|
||||||
|
VAR_NEW="HOMEBREW_${VAR}"
|
||||||
|
# TODO: find a better solution than this.
|
||||||
|
env | grep -q "$VAR_NEW" && continue
|
||||||
|
export "$VAR_NEW"="${!VAR}"
|
||||||
|
done
|
||||||
|
|
||||||
if [[ -n "$HOMEBREW_ENV_FILTERING" ]]
|
if [[ -n "$HOMEBREW_ENV_FILTERING" ]]
|
||||||
then
|
then
|
||||||
PATH="/usr/bin:/bin:/usr/sbin:/sbin"
|
PATH="/usr/bin:/bin:/usr/sbin:/sbin"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user