cmd/shellenv.sh: make sure the current Homebrew is initialized correctly
This commit is contained in:
parent
7cc37fb7f8
commit
6cd2192c6f
@ -3,20 +3,23 @@
|
||||
#: Print export statements. When run in a shell, this installation of Homebrew will be added to your `PATH`, `MANPATH`, and `INFOPATH`.
|
||||
#:
|
||||
#: The variables `HOMEBREW_PREFIX`, `HOMEBREW_CELLAR` and `HOMEBREW_REPOSITORY` are also exported to avoid querying them multiple times.
|
||||
#: The variable `HOMEBREW_SHELLENV_SET` will be exported to avoid adding duplicate entries to the environment variables.
|
||||
#: The variables and `HOMEBREW_SHELLENV_PREFIX` and `HOMEBREW_SHELLENV_SET` will be exported to avoid adding duplicate entries to the environment variables.
|
||||
#: Consider adding evaluation of this command's output to your dotfiles (e.g. `~/.profile`, `~/.bash_profile`, or `~/.zprofile`) with: `eval $(brew shellenv)`
|
||||
|
||||
# HOMEBREW_CELLAR and HOMEBREW_PREFIX are set by extend/ENV/super.rb
|
||||
# HOMEBREW_REPOSITORY is set by bin/brew
|
||||
# shellcheck disable=SC2154
|
||||
homebrew-shellenv() {
|
||||
[[ "${HOMEBREW_SHELLENV_PREFIX}" == "${HOMEBREW_PREFIX}" ]] && return
|
||||
|
||||
case "$(/bin/ps -p "${PPID}" -c -o comm=)" in
|
||||
fish | -fish)
|
||||
echo "set -gx HOMEBREW_PREFIX \"${HOMEBREW_PREFIX}\";"
|
||||
echo "set -gx HOMEBREW_CELLAR \"${HOMEBREW_CELLAR}\";"
|
||||
echo "set -gx HOMEBREW_REPOSITORY \"${HOMEBREW_REPOSITORY}\";"
|
||||
[[ ":${HOMEBREW_SHELLENV_SET}:" == *":${HOMEBREW_PREFIX}:"* ]] && return
|
||||
echo "set -gx HOMEBREW_SHELLENV_PREFIX \"${HOMEBREW_PREFIX}\";"
|
||||
echo "set -q PATH; or set PATH ''; set -gx PATH \"${HOMEBREW_PREFIX}/bin\" \"${HOMEBREW_PREFIX}/sbin\" \$PATH;"
|
||||
[[ ":${HOMEBREW_SHELLENV_SET}:" == *":${HOMEBREW_PREFIX}:"* ]] && return
|
||||
echo "set -q MANPATH; or set MANPATH ''; set -gx MANPATH \"${HOMEBREW_PREFIX}/share/man\" \$MANPATH;"
|
||||
echo "set -q INFOPATH; or set INFOPATH ''; set -gx INFOPATH \"${HOMEBREW_PREFIX}/share/info\" \$INFOPATH;"
|
||||
echo "set -q HOMEBREW_SHELLENV_SET; or set HOMEBREW_SHELLENV_SET ''; set -gx HOMEBREW_SHELLENV_SET \"${HOMEBREW_PREFIX}\" \$HOMEBREW_SHELLENV_SET;"
|
||||
@ -25,8 +28,9 @@ homebrew-shellenv() {
|
||||
echo "setenv HOMEBREW_PREFIX ${HOMEBREW_PREFIX};"
|
||||
echo "setenv HOMEBREW_CELLAR ${HOMEBREW_CELLAR};"
|
||||
echo "setenv HOMEBREW_REPOSITORY ${HOMEBREW_REPOSITORY};"
|
||||
[[ ":${HOMEBREW_SHELLENV_SET}:" == *":${HOMEBREW_PREFIX}:"* ]] && return
|
||||
echo "setenv HOMEBREW_SHELLENV_PREFIX ${HOMEBREW_PREFIX};"
|
||||
echo "setenv PATH ${HOMEBREW_PREFIX}/bin:${HOMEBREW_PREFIX}/sbin:\$PATH;"
|
||||
[[ ":${HOMEBREW_SHELLENV_SET}:" == *":${HOMEBREW_PREFIX}:"* ]] && return
|
||||
echo "setenv MANPATH ${HOMEBREW_PREFIX}/share/man\`[ \${?MANPATH} == 1 ] && echo \":\${MANPATH}\"\`:;"
|
||||
echo "setenv INFOPATH ${HOMEBREW_PREFIX}/share/info\`[ \${?INFOPATH} == 1 ] && echo \":\${INFOPATH}\"\`;"
|
||||
echo "setenv HOMEBREW_SHELLENV_SET ${HOMEBREW_PREFIX}\`[ \${?HOMEBREW_SHELLENV_SET} == 1 ] && echo \":\${HOMEBREW_SHELLENV_SET}\"\`;"
|
||||
@ -35,8 +39,9 @@ homebrew-shellenv() {
|
||||
echo "export HOMEBREW_PREFIX=\"${HOMEBREW_PREFIX}\";"
|
||||
echo "export HOMEBREW_CELLAR=\"${HOMEBREW_CELLAR}\";"
|
||||
echo "export HOMEBREW_REPOSITORY=\"${HOMEBREW_REPOSITORY}\";"
|
||||
[[ ":${HOMEBREW_SHELLENV_SET}:" == *":${HOMEBREW_PREFIX}:"* ]] && return
|
||||
echo "export HOMEBREW_SHELLENV_PREFIX=\"${HOMEBREW_PREFIX}\";"
|
||||
echo "export PATH=\"${HOMEBREW_PREFIX}/bin:${HOMEBREW_PREFIX}/sbin\${PATH+:\$PATH}\";"
|
||||
[[ ":${HOMEBREW_SHELLENV_SET}:" == *":${HOMEBREW_PREFIX}:"* ]] && return
|
||||
echo "export MANPATH=\"${HOMEBREW_PREFIX}/share/man\${MANPATH+:\$MANPATH}:\";"
|
||||
echo "export INFOPATH=\"${HOMEBREW_PREFIX}/share/info:\${INFOPATH:-}\";"
|
||||
echo "export HOMEBREW_SHELLENV_SET=\"${HOMEBREW_PREFIX}\${HOMEBREW_SHELLENV_SET+:\$HOMEBREW_SHELLENV_SET}\";"
|
||||
|
||||
@ -305,9 +305,13 @@ module Homebrew
|
||||
"useful to avoid long-running Homebrew commands being killed due to no output.",
|
||||
boolean: true,
|
||||
},
|
||||
HOMEBREW_SHELLENV_PREFIX: {
|
||||
description: "The lastest Homebrew prefix initialized by `brew shellenv`. If it is equal to " \
|
||||
"the current Homebrew prefix, `brew shellenv` will skip all export statements.",
|
||||
},
|
||||
HOMEBREW_SHELLENV_SET: {
|
||||
description: "A colon separated list of brew prefixes. If it is set and contains the current brew prefix, " \
|
||||
"`brew shellenv` skips export statements for paths.",
|
||||
description: "A colon separated list of Homebrew prefixes. If it is set and contains the current " \
|
||||
"Homebrew prefix, `brew shellenv` will skip export statements for paths.",
|
||||
},
|
||||
all_proxy: {
|
||||
description: "Use this SOCKS5 proxy for `curl`(1), `git`(1) and `svn`(1) when downloading through Homebrew.",
|
||||
|
||||
@ -565,7 +565,7 @@ The search for *`text`* is extended online to `homebrew/core` and `homebrew/cask
|
||||
Print export statements. When run in a shell, this installation of Homebrew will be added to your `PATH`, `MANPATH`, and `INFOPATH`.
|
||||
|
||||
The variables `HOMEBREW_PREFIX`, `HOMEBREW_CELLAR` and `HOMEBREW_REPOSITORY` are also exported to avoid querying them multiple times.
|
||||
The variable `HOMEBREW_SHELLENV_SET` will be exported to avoid adding duplicate entries to the environment variables.
|
||||
The variables and `HOMEBREW_SHELLENV_PREFIX` and `HOMEBREW_SHELLENV_SET` will be exported to avoid adding duplicate entries to the environment variables.
|
||||
Consider adding evaluation of this command's output to your dotfiles (e.g. `~/.profile`, `~/.bash_profile`, or `~/.zprofile`) with: `eval $(brew shellenv)`
|
||||
|
||||
### `tap` [*`options`*] [*`user`*`/`*`repo`*] [*`URL`*]
|
||||
@ -2088,8 +2088,11 @@ example, run `export HOMEBREW_NO_INSECURE_REDIRECT=1` rather than just
|
||||
- `HOMEBREW_VERBOSE_USING_DOTS`
|
||||
<br>If set, verbose output will print a `.` no more than once a minute. This can be useful to avoid long-running Homebrew commands being killed due to no output.
|
||||
|
||||
- `HOMEBREW_SHELLENV_PREFIX`
|
||||
<br>The lastest Homebrew prefix initialized by `brew shellenv`. If it is equal to the current Homebrew prefix, `brew shellenv` will skip all export statements.
|
||||
|
||||
- `HOMEBREW_SHELLENV_SET`
|
||||
<br>A colon separated list of brew prefixes. If it is set and contains the current brew prefix, `brew shellenv` skips export statements for paths.
|
||||
<br>A colon separated list of Homebrew prefixes. If it is set and contains the current Homebrew prefix, `brew shellenv` will skip export statements for paths.
|
||||
|
||||
- `all_proxy`
|
||||
<br>Use this SOCKS5 proxy for `curl`(1), `git`(1) and `svn`(1) when downloading through Homebrew.
|
||||
|
||||
@ -784,7 +784,7 @@ Search for \fItext\fR in the given database\.
|
||||
Print export statements\. When run in a shell, this installation of Homebrew will be added to your \fBPATH\fR, \fBMANPATH\fR, and \fBINFOPATH\fR\.
|
||||
.
|
||||
.P
|
||||
The variables \fBHOMEBREW_PREFIX\fR, \fBHOMEBREW_CELLAR\fR and \fBHOMEBREW_REPOSITORY\fR are also exported to avoid querying them multiple times\. The variable \fBHOMEBREW_SHELLENV_SET\fR will be exported to avoid adding duplicate entries to the environment variables\. Consider adding evaluation of this command\'s output to your dotfiles (e\.g\. \fB~/\.profile\fR, \fB~/\.bash_profile\fR, or \fB~/\.zprofile\fR) with: \fBeval $(brew shellenv)\fR
|
||||
The variables \fBHOMEBREW_PREFIX\fR, \fBHOMEBREW_CELLAR\fR and \fBHOMEBREW_REPOSITORY\fR are also exported to avoid querying them multiple times\. The variables and \fBHOMEBREW_SHELLENV_PREFIX\fR and \fBHOMEBREW_SHELLENV_SET\fR will be exported to avoid adding duplicate entries to the environment variables\. Consider adding evaluation of this command\'s output to your dotfiles (e\.g\. \fB~/\.profile\fR, \fB~/\.bash_profile\fR, or \fB~/\.zprofile\fR) with: \fBeval $(brew shellenv)\fR
|
||||
.
|
||||
.SS "\fBtap\fR [\fIoptions\fR] [\fIuser\fR\fB/\fR\fIrepo\fR] [\fIURL\fR]"
|
||||
Tap a formula repository\.
|
||||
@ -3040,10 +3040,16 @@ If set, always assume \fB\-\-debug\fR when running commands\.
|
||||
If set, verbose output will print a \fB\.\fR no more than once a minute\. This can be useful to avoid long\-running Homebrew commands being killed due to no output\.
|
||||
.
|
||||
.TP
|
||||
\fBHOMEBREW_SHELLENV_PREFIX\fR
|
||||
.
|
||||
.br
|
||||
The lastest Homebrew prefix initialized by \fBbrew shellenv\fR\. If it is equal to the current Homebrew prefix, \fBbrew shellenv\fR will skip all export statements\.
|
||||
.
|
||||
.TP
|
||||
\fBHOMEBREW_SHELLENV_SET\fR
|
||||
.
|
||||
.br
|
||||
A colon separated list of brew prefixes\. If it is set and contains the current brew prefix, \fBbrew shellenv\fR skips export statements for paths\.
|
||||
A colon separated list of Homebrew prefixes\. If it is set and contains the current Homebrew prefix, \fBbrew shellenv\fR will skip export statements for paths\.
|
||||
.
|
||||
.TP
|
||||
\fBall_proxy\fR
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user