Skip to content
Snippets Groups Projects
Commit 8205e61e authored by Mike McQuaid's avatar Mike McQuaid
Browse files

More environment filtering tweaks

- only document HOMEBREW_* variables in the manpage (although still
  read from all the original environment variables).
- resort manpage environment variables in alphabetical order
- check the original path for trailing slashes
parent 459fef3b
No related branches found
No related tags found
No related merge requests found
...@@ -100,7 +100,7 @@ module Homebrew ...@@ -100,7 +100,7 @@ module Homebrew
# See https://github.com/Homebrew/legacy-homebrew/pull/9986 # See https://github.com/Homebrew/legacy-homebrew/pull/9986
def check_path_for_trailing_slashes def check_path_for_trailing_slashes
bad_paths = PATH.new(ENV["PATH"]).select { |p| p.end_with?("/") } bad_paths = PATH.new(ENV["HOMEBREW_PATH"]).select { |p| p.end_with?("/") }
return if bad_paths.empty? return if bad_paths.empty?
inject_file_list bad_paths, <<-EOS.undent inject_file_list bad_paths, <<-EOS.undent
......
...@@ -520,6 +520,9 @@ class S3DownloadStrategy < CurlDownloadStrategy ...@@ -520,6 +520,9 @@ class S3DownloadStrategy < CurlDownloadStrategy
bucket = $1 bucket = $1
key = $2 key = $2
ENV["AWS_ACCESS_KEY_ID"] = ENV["HOMEBREW_AWS_ACCESS_KEY_ID"]
ENV["AWS_SECRET_ACCESS_KEY"] = ENV["HOMEBREW_AWS_SECRET_ACCESS_KEY"]
obj = AWS::S3.new.buckets[bucket].objects[key] obj = AWS::S3.new.buckets[bucket].objects[key]
begin begin
s3url = obj.url_for(:get) s3url = obj.url_for(:get)
......
...@@ -98,8 +98,15 @@ can take several different forms: ...@@ -98,8 +98,15 @@ can take several different forms:
The formula file will be cached for later use. The formula file will be cached for later use.
## ENVIRONMENT ## ENVIRONMENT
* `HOMEBREW_ARTIFACT_DOMAIN`:
If set, instructs Homebrew to use the given URL as a download mirror for bottles and binaries.
* `HOMEBREW_AUTO_UPDATE_SECS`:
If set, Homebrew will only check for autoupdates once per this seconds interval.
*Default:* `60`.
* `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`: * `HOMEBREW_AWS_ACCESS_KEY_ID`, `HOMEBREW_AWS_SECRET_ACCESS_KEY`:
When using the `S3` download strategy, Homebrew will look in When using the `S3` download strategy, Homebrew will look in
these variables for access credentials (see these variables for access credentials (see
<https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-environment> <https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-environment>
...@@ -107,30 +114,9 @@ can take several different forms: ...@@ -107,30 +114,9 @@ can take several different forms:
the `S3` download strategy will download with a public the `S3` download strategy will download with a public
(unsigned) URL. (unsigned) URL.
* `BROWSER`:
If set, and `HOMEBREW_BROWSER` is not, use `BROWSER` as the web browser
when opening project homepages.
* `EDITOR`:
If set, and `HOMEBREW_EDITOR` and `VISUAL` are not, use `EDITOR` as the text editor.
* `GIT`:
When using Git, Homebrew will use `GIT` if set,
a Homebrew-built Git if installed, or the system-provided binary.
Set this to force Homebrew to use a particular git binary.
* `HOMEBREW_BOTTLE_DOMAIN`: * `HOMEBREW_BOTTLE_DOMAIN`:
If set, instructs Homebrew to use the given URL as a download mirror for bottles. If set, instructs Homebrew to use the given URL as a download mirror for bottles.
* `HOMEBREW_ARTIFACT_DOMAIN`:
If set, instructs Homebrew to use the given URL as a download mirror for bottles and binaries.
* `HOMEBREW_AUTO_UPDATE_SECS`:
If set, Homebrew will only check for autoupdates once per this seconds interval.
*Default:* `60`.
* `HOMEBREW_BROWSER`: * `HOMEBREW_BROWSER`:
If set, uses this setting as the browser when opening project homepages, If set, uses this setting as the browser when opening project homepages,
instead of the OS default browser. instead of the OS default browser.
...@@ -178,6 +164,12 @@ can take several different forms: ...@@ -178,6 +164,12 @@ can take several different forms:
If set, Homebrew will always use its vendored, relocatable Ruby 2.0 version If set, Homebrew will always use its vendored, relocatable Ruby 2.0 version
even if the system version of Ruby is >=2.0. even if the system version of Ruby is >=2.0.
* `HOMEBREW_GIT`:
When using Git, Homebrew will use `GIT` if set,
a Homebrew-built Git if installed, or the system-provided binary.
Set this to force Homebrew to use a particular git binary.
* `HOMEBREW_GITHUB_API_TOKEN`: * `HOMEBREW_GITHUB_API_TOKEN`:
A personal access token for the GitHub API, which you can create at A personal access token for the GitHub API, which you can create at
<https://github.com/settings/tokens>. If set, GitHub will allow you a <https://github.com/settings/tokens>. If set, GitHub will allow you a
...@@ -243,9 +235,6 @@ can take several different forms: ...@@ -243,9 +235,6 @@ can take several different forms:
* `HOMEBREW_VERBOSE`: * `HOMEBREW_VERBOSE`:
If set, Homebrew always assumes `--verbose` when running commands. If set, Homebrew always assumes `--verbose` when running commands.
* `VISUAL`:
If set, and `HOMEBREW_EDITOR` is not, use `VISUAL` as the text editor.
## USING HOMEBREW BEHIND A PROXY ## USING HOMEBREW BEHIND A PROXY
Homebrew uses several commands for downloading files (e.g. `curl`, `git`, `svn`). Homebrew uses several commands for downloading files (e.g. `curl`, `git`, `svn`).
......
...@@ -86,7 +86,6 @@ fi ...@@ -86,7 +86,6 @@ fi
case "$(lowercase "$SCM_FILE")" in case "$(lowercase "$SCM_FILE")" in
git) git)
[[ -n "$HOMEBREW_GIT" ]] && safe_exec "$(which "$HOMEBREW_GIT")" "$@" [[ -n "$HOMEBREW_GIT" ]] && safe_exec "$(which "$HOMEBREW_GIT")" "$@"
[[ -n "$GIT" ]] && safe_exec "$(which "$GIT")" "$@"
;; ;;
svn) svn)
[[ -n "$HOMEBREW_SVN" ]] && safe_exec "$(which "$HOMEBREW_SVN")" "$@" [[ -n "$HOMEBREW_SVN" ]] && safe_exec "$(which "$HOMEBREW_SVN")" "$@"
......
...@@ -7,7 +7,7 @@ describe Homebrew::Diagnostic::Checks do ...@@ -7,7 +7,7 @@ describe Homebrew::Diagnostic::Checks do
end end
specify "#check_path_for_trailing_slashes" do specify "#check_path_for_trailing_slashes" do
ENV["PATH"] += File::PATH_SEPARATOR + "/foo/bar/" ENV["HOMEBREW_PATH"] += File::PATH_SEPARATOR + "/foo/bar/"
expect(subject.check_path_for_trailing_slashes) expect(subject.check_path_for_trailing_slashes)
.to match("Some directories in your path end in a slash") .to match("Some directories in your path end in a slash")
end end
......
...@@ -320,7 +320,7 @@ def which_all(cmd, path = ENV["PATH"]) ...@@ -320,7 +320,7 @@ def which_all(cmd, path = ENV["PATH"])
end end
def which_editor def which_editor
editor = ENV.values_at("HOMEBREW_EDITOR", "VISUAL").compact.reject(&:empty?).first editor = ENV.values_at("HOMEBREW_EDITOR", "HOMEBREW_VISUAL").compact.reject(&:empty?).first
if editor if editor
editor_name, _, editor_args = editor.partition " " editor_name, _, editor_args = editor.partition " "
editor_path = which(editor_name, ENV["HOMEBREW_PATH"]) editor_path = which(editor_name, ENV["HOMEBREW_PATH"])
...@@ -356,7 +356,7 @@ def exec_editor(*args) ...@@ -356,7 +356,7 @@ def exec_editor(*args)
end end
def exec_browser(*args) def exec_browser(*args)
browser = ENV["HOMEBREW_BROWSER"] || ENV["BROWSER"] browser = ENV["HOMEBREW_BROWSER"]
browser ||= OS::PATH_OPEN if defined?(OS::PATH_OPEN) browser ||= OS::PATH_OPEN if defined?(OS::PATH_OPEN)
return unless browser return unless browser
safe_exec(browser, *args) safe_exec(browser, *args)
......
...@@ -44,7 +44,10 @@ fi ...@@ -44,7 +44,10 @@ fi
HOMEBREW_LIBRARY="$HOMEBREW_REPOSITORY/Library" HOMEBREW_LIBRARY="$HOMEBREW_REPOSITORY/Library"
for VAR in EDITOR PATH BINTRAY_USER BINTRAY_KEY # Whitelist and copy to HOMEBREW_* all variables previously mentioned in
# manpage or used elsewhere by Homebrew.
for VAR in AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY BINTRAY_USER BINTRAY_KEY \
BROWSER EDITOR GIT PATH VISUAL
do do
VAR_NEW="HOMEBREW_${VAR}" VAR_NEW="HOMEBREW_${VAR}"
[[ -n "${!VAR_NEW}" ]] && continue [[ -n "${!VAR_NEW}" ]] && continue
......
...@@ -910,8 +910,15 @@ can take several different forms: ...@@ -910,8 +910,15 @@ can take several different forms:
The formula file will be cached for later use. The formula file will be cached for later use.
## ENVIRONMENT ## ENVIRONMENT
* `HOMEBREW_ARTIFACT_DOMAIN`:
If set, instructs Homebrew to use the given URL as a download mirror for bottles and binaries.
* `HOMEBREW_AUTO_UPDATE_SECS`:
If set, Homebrew will only check for autoupdates once per this seconds interval.
*Default:* `60`.
* `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`: * `HOMEBREW_AWS_ACCESS_KEY_ID`, `HOMEBREW_AWS_SECRET_ACCESS_KEY`:
When using the `S3` download strategy, Homebrew will look in When using the `S3` download strategy, Homebrew will look in
these variables for access credentials (see these variables for access credentials (see
<https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-environment> <https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-environment>
...@@ -919,30 +926,9 @@ can take several different forms: ...@@ -919,30 +926,9 @@ can take several different forms:
the `S3` download strategy will download with a public the `S3` download strategy will download with a public
(unsigned) URL. (unsigned) URL.
* `BROWSER`:
If set, and `HOMEBREW_BROWSER` is not, use `BROWSER` as the web browser
when opening project homepages.
* `EDITOR`:
If set, and `HOMEBREW_EDITOR` and `VISUAL` are not, use `EDITOR` as the text editor.
* `GIT`:
When using Git, Homebrew will use `GIT` if set,
a Homebrew-built Git if installed, or the system-provided binary.
Set this to force Homebrew to use a particular git binary.
* `HOMEBREW_BOTTLE_DOMAIN`: * `HOMEBREW_BOTTLE_DOMAIN`:
If set, instructs Homebrew to use the given URL as a download mirror for bottles. If set, instructs Homebrew to use the given URL as a download mirror for bottles.
* `HOMEBREW_ARTIFACT_DOMAIN`:
If set, instructs Homebrew to use the given URL as a download mirror for bottles and binaries.
* `HOMEBREW_AUTO_UPDATE_SECS`:
If set, Homebrew will only check for autoupdates once per this seconds interval.
*Default:* `60`.
* `HOMEBREW_BROWSER`: * `HOMEBREW_BROWSER`:
If set, uses this setting as the browser when opening project homepages, If set, uses this setting as the browser when opening project homepages,
instead of the OS default browser. instead of the OS default browser.
...@@ -990,6 +976,12 @@ can take several different forms: ...@@ -990,6 +976,12 @@ can take several different forms:
If set, Homebrew will always use its vendored, relocatable Ruby 2.0 version If set, Homebrew will always use its vendored, relocatable Ruby 2.0 version
even if the system version of Ruby is >=2.0. even if the system version of Ruby is >=2.0.
* `HOMEBREW_GIT`:
When using Git, Homebrew will use `GIT` if set,
a Homebrew-built Git if installed, or the system-provided binary.
Set this to force Homebrew to use a particular git binary.
* `HOMEBREW_GITHUB_API_TOKEN`: * `HOMEBREW_GITHUB_API_TOKEN`:
A personal access token for the GitHub API, which you can create at A personal access token for the GitHub API, which you can create at
<https://github.com/settings/tokens>. If set, GitHub will allow you a <https://github.com/settings/tokens>. If set, GitHub will allow you a
...@@ -1055,9 +1047,6 @@ can take several different forms: ...@@ -1055,9 +1047,6 @@ can take several different forms:
* `HOMEBREW_VERBOSE`: * `HOMEBREW_VERBOSE`:
If set, Homebrew always assumes `--verbose` when running commands. If set, Homebrew always assumes `--verbose` when running commands.
* `VISUAL`:
If set, and `HOMEBREW_EDITOR` is not, use `VISUAL` as the text editor.
## USING HOMEBREW BEHIND A PROXY ## USING HOMEBREW BEHIND A PROXY
Homebrew uses several commands for downloading files (e.g. `curl`, `git`, `svn`). Homebrew uses several commands for downloading files (e.g. `curl`, `git`, `svn`).
......
...@@ -941,29 +941,6 @@ Homebrew can install formulae via URL, e\.g\. \fBhttps://raw\.github\.com/Homebr ...@@ -941,29 +941,6 @@ Homebrew can install formulae via URL, e\.g\. \fBhttps://raw\.github\.com/Homebr
.SH "ENVIRONMENT" .SH "ENVIRONMENT"
. .
.TP .TP
\fBAWS_ACCESS_KEY_ID\fR, \fBAWS_SECRET_ACCESS_KEY\fR
When using the \fBS3\fR download strategy, Homebrew will look in these variables for access credentials (see \fIhttps://docs\.aws\.amazon\.com/cli/latest/userguide/cli\-chap\-getting\-started\.html#cli\-environment\fR to retrieve these access credentials from AWS)\. If they are not set, the \fBS3\fR download strategy will download with a public (unsigned) URL\.
.
.TP
\fBBROWSER\fR
If set, and \fBHOMEBREW_BROWSER\fR is not, use \fBBROWSER\fR as the web browser when opening project homepages\.
.
.TP
\fBEDITOR\fR
If set, and \fBHOMEBREW_EDITOR\fR and \fBVISUAL\fR are not, use \fBEDITOR\fR as the text editor\.
.
.TP
\fBGIT\fR
When using Git, Homebrew will use \fBGIT\fR if set, a Homebrew\-built Git if installed, or the system\-provided binary\.
.
.IP
Set this to force Homebrew to use a particular git binary\.
.
.TP
\fBHOMEBREW_BOTTLE_DOMAIN\fR
If set, instructs Homebrew to use the given URL as a download mirror for bottles\.
.
.TP
\fBHOMEBREW_ARTIFACT_DOMAIN\fR \fBHOMEBREW_ARTIFACT_DOMAIN\fR
If set, instructs Homebrew to use the given URL as a download mirror for bottles and binaries\. If set, instructs Homebrew to use the given URL as a download mirror for bottles and binaries\.
. .
...@@ -975,6 +952,14 @@ If set, Homebrew will only check for autoupdates once per this seconds interval\ ...@@ -975,6 +952,14 @@ If set, Homebrew will only check for autoupdates once per this seconds interval\
\fIDefault:\fR \fB60\fR\. \fIDefault:\fR \fB60\fR\.
. .
.TP .TP
\fBHOMEBREW_AWS_ACCESS_KEY_ID\fR, \fBHOMEBREW_AWS_SECRET_ACCESS_KEY\fR
When using the \fBS3\fR download strategy, Homebrew will look in these variables for access credentials (see \fIhttps://docs\.aws\.amazon\.com/cli/latest/userguide/cli\-chap\-getting\-started\.html#cli\-environment\fR to retrieve these access credentials from AWS)\. If they are not set, the \fBS3\fR download strategy will download with a public (unsigned) URL\.
.
.TP
\fBHOMEBREW_BOTTLE_DOMAIN\fR
If set, instructs Homebrew to use the given URL as a download mirror for bottles\.
.
.TP
\fBHOMEBREW_BROWSER\fR \fBHOMEBREW_BROWSER\fR
If set, uses this setting as the browser when opening project homepages, instead of the OS default browser\. If set, uses this setting as the browser when opening project homepages, instead of the OS default browser\.
. .
...@@ -1021,6 +1006,13 @@ If set, Homebrew will use this editor when editing a single formula, or several ...@@ -1021,6 +1006,13 @@ If set, Homebrew will use this editor when editing a single formula, or several
If set, Homebrew will always use its vendored, relocatable Ruby 2\.0 version even if the system version of Ruby is >=2\.0\. If set, Homebrew will always use its vendored, relocatable Ruby 2\.0 version even if the system version of Ruby is >=2\.0\.
. .
.TP .TP
\fBHOMEBREW_GIT\fR
When using Git, Homebrew will use \fBGIT\fR if set, a Homebrew\-built Git if installed, or the system\-provided binary\.
.
.IP
Set this to force Homebrew to use a particular git binary\.
.
.TP
\fBHOMEBREW_GITHUB_API_TOKEN\fR \fBHOMEBREW_GITHUB_API_TOKEN\fR
A personal access token for the GitHub API, which you can create at \fIhttps://github\.com/settings/tokens\fR\. If set, GitHub will allow you a greater number of API requests\. See \fIhttps://developer\.github\.com/v3/#rate\-limiting\fR for more information\. Homebrew uses the GitHub API for features such as \fBbrew search\fR\. A personal access token for the GitHub API, which you can create at \fIhttps://github\.com/settings/tokens\fR\. If set, GitHub will allow you a greater number of API requests\. See \fIhttps://developer\.github\.com/v3/#rate\-limiting\fR for more information\. Homebrew uses the GitHub API for features such as \fBbrew search\fR\.
. .
...@@ -1086,10 +1078,6 @@ This issue typically occurs when using FileVault or custom SSD configurations\. ...@@ -1086,10 +1078,6 @@ This issue typically occurs when using FileVault or custom SSD configurations\.
\fBHOMEBREW_VERBOSE\fR \fBHOMEBREW_VERBOSE\fR
If set, Homebrew always assumes \fB\-\-verbose\fR when running commands\. If set, Homebrew always assumes \fB\-\-verbose\fR when running commands\.
. .
.TP
\fBVISUAL\fR
If set, and \fBHOMEBREW_EDITOR\fR is not, use \fBVISUAL\fR as the text editor\.
.
.SH "USING HOMEBREW BEHIND A PROXY" .SH "USING HOMEBREW BEHIND A PROXY"
Homebrew uses several commands for downloading files (e\.g\. \fBcurl\fR, \fBgit\fR, \fBsvn\fR)\. Many of these tools can download via a proxy\. It\'s common for these tools to read proxy parameters from environment variables\. Homebrew uses several commands for downloading files (e\.g\. \fBcurl\fR, \fBgit\fR, \fBsvn\fR)\. Many of these tools can download via a proxy\. It\'s common for these tools to read proxy parameters from environment variables\.
. .
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment