Merge pull request #11789 from XuehaiPan/master
cmd/shellenv.sh: make `brew shellenv` idempotent
This commit is contained in:
commit
f22d140869
@ -3,17 +3,21 @@
|
||||
#: 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_PREFIX` 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}\";"
|
||||
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;"
|
||||
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;"
|
||||
@ -22,6 +26,7 @@ homebrew-shellenv() {
|
||||
echo "setenv HOMEBREW_PREFIX ${HOMEBREW_PREFIX};"
|
||||
echo "setenv HOMEBREW_CELLAR ${HOMEBREW_CELLAR};"
|
||||
echo "setenv HOMEBREW_REPOSITORY ${HOMEBREW_REPOSITORY};"
|
||||
echo "setenv HOMEBREW_SHELLENV_PREFIX ${HOMEBREW_PREFIX};"
|
||||
echo "setenv PATH ${HOMEBREW_PREFIX}/bin:${HOMEBREW_PREFIX}/sbin:\$PATH;"
|
||||
echo "setenv MANPATH ${HOMEBREW_PREFIX}/share/man\`[ \${?MANPATH} == 1 ] && echo \":\${MANPATH}\"\`:;"
|
||||
echo "setenv INFOPATH ${HOMEBREW_PREFIX}/share/info\`[ \${?INFOPATH} == 1 ] && echo \":\${INFOPATH}\"\`;"
|
||||
@ -30,6 +35,7 @@ homebrew-shellenv() {
|
||||
echo "export HOMEBREW_PREFIX=\"${HOMEBREW_PREFIX}\";"
|
||||
echo "export HOMEBREW_CELLAR=\"${HOMEBREW_CELLAR}\";"
|
||||
echo "export HOMEBREW_REPOSITORY=\"${HOMEBREW_REPOSITORY}\";"
|
||||
echo "export HOMEBREW_SHELLENV_PREFIX=\"${HOMEBREW_PREFIX}\";"
|
||||
echo "export PATH=\"${HOMEBREW_PREFIX}/bin:${HOMEBREW_PREFIX}/sbin\${PATH+:\$PATH}\";"
|
||||
echo "export MANPATH=\"${HOMEBREW_PREFIX}/share/man\${MANPATH+:\$MANPATH}:\";"
|
||||
echo "export INFOPATH=\"${HOMEBREW_PREFIX}/share/info:\${INFOPATH:-}\";"
|
||||
|
@ -569,6 +569,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_PREFIX` 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`*]
|
||||
|
@ -1,7 +1,7 @@
|
||||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "BREW" "1" "July 2021" "Homebrew" "brew"
|
||||
.TH "BREW" "1" "August 2021" "Homebrew" "brew"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBbrew\fR \- The Missing Package Manager for macOS (or Linux)
|
||||
@ -792,7 +792,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\. 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 variable \fBHOMEBREW_SHELLENV_PREFIX\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\.
|
||||
|
Loading…
x
Reference in New Issue
Block a user