diff --git a/Library/Homebrew/cmd/shellenv.sh b/Library/Homebrew/cmd/shellenv.sh index 326807d67a..11c1f11852 100644 --- a/Library/Homebrew/cmd/shellenv.sh +++ b/Library/Homebrew/cmd/shellenv.sh @@ -15,31 +15,31 @@ homebrew-shellenv() { echo "set -gx HOMEBREW_PREFIX \"${HOMEBREW_PREFIX}\";" echo "set -gx HOMEBREW_CELLAR \"${HOMEBREW_CELLAR}\";" echo "set -gx HOMEBREW_REPOSITORY \"${HOMEBREW_REPOSITORY}\";" - [[ -n "${HOMEBREW_SHELLENV_SET}" ]] && return + [[ ":${HOMEBREW_SHELLENV_SET}:" == *":${HOMEBREW_PREFIX}:"* ]] && return 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;" - echo "set -gx HOMEBREW_SHELLENV_SET 1;" + echo "set -q HOMEBREW_SHELLENV_SET; or set HOMEBREW_SHELLENV_SET ''; set -gx HOMEBREW_SHELLENV_SET \"${HOMEBREW_PREFIX}\" \$HOMEBREW_SHELLENV_SET;" ;; csh | -csh | tcsh | -tcsh) echo "setenv HOMEBREW_PREFIX ${HOMEBREW_PREFIX};" echo "setenv HOMEBREW_CELLAR ${HOMEBREW_CELLAR};" echo "setenv HOMEBREW_REPOSITORY ${HOMEBREW_REPOSITORY};" - [[ -n "${HOMEBREW_SHELLENV_SET}" ]] && return + [[ ":${HOMEBREW_SHELLENV_SET}:" == *":${HOMEBREW_PREFIX}:"* ]] && return 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}\"\`;" - echo "setenv HOMEBREW_SHELLENV_SET 1;" + echo "setenv HOMEBREW_SHELLENV_SET ${HOMEBREW_PREFIX}\`[ \${?HOMEBREW_SHELLENV_SET} == 1 ] && echo \":\${HOMEBREW_SHELLENV_SET}\"\`;" ;; *) echo "export HOMEBREW_PREFIX=\"${HOMEBREW_PREFIX}\";" echo "export HOMEBREW_CELLAR=\"${HOMEBREW_CELLAR}\";" echo "export HOMEBREW_REPOSITORY=\"${HOMEBREW_REPOSITORY}\";" - [[ -n "${HOMEBREW_SHELLENV_SET}" ]] && return + [[ ":${HOMEBREW_SHELLENV_SET}:" == *":${HOMEBREW_PREFIX}:"* ]] && return 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:-}\";" - echo "export HOMEBREW_SHELLENV_SET=1;" + echo "export HOMEBREW_SHELLENV_SET=\"${HOMEBREW_PREFIX}\${HOMEBREW_SHELLENV_SET+:\$HOMEBREW_SHELLENV_SET}\";" ;; esac } diff --git a/Library/Homebrew/env_config.rb b/Library/Homebrew/env_config.rb index ed7519c930..95a5422055 100644 --- a/Library/Homebrew/env_config.rb +++ b/Library/Homebrew/env_config.rb @@ -306,8 +306,8 @@ module Homebrew boolean: true, }, HOMEBREW_SHELLENV_SET: { - description: "If set, `brew shellenv` skips export statements for paths.", - boolean: true, + 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.", }, all_proxy: { description: "Use this SOCKS5 proxy for `curl`(1), `git`(1) and `svn`(1) when downloading through Homebrew.", diff --git a/docs/Manpage.md b/docs/Manpage.md index 5ab46f5a5a..3d2cb825df 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -2089,7 +2089,7 @@ example, run `export HOMEBREW_NO_INSECURE_REDIRECT=1` rather than just
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_SET` -
If set, `brew shellenv` skips export statements for paths. +
A colon separated list of brew prefixes. If it is set and contains the current brew prefix, `brew shellenv` skips export statements for paths. - `all_proxy`
Use this SOCKS5 proxy for `curl`(1), `git`(1) and `svn`(1) when downloading through Homebrew. diff --git a/manpages/brew.1 b/manpages/brew.1 index 04f46b8958..acecd9fab0 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -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) @@ -3043,7 +3043,7 @@ If set, verbose output will print a \fB\.\fR no more than once a minute\. This c \fBHOMEBREW_SHELLENV_SET\fR . .br -If set, \fBbrew shellenv\fR skips export statements for paths\. +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\. . .TP \fBall_proxy\fR