mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Merge pull request #15363 from halostatue/shellenv-shell-parameter
Allow brew shellenv to accept a shell name param
This commit is contained in:
commit
628626b078
@ -81,7 +81,7 @@ case "$*" in
|
||||
;;
|
||||
shellenv)
|
||||
source "${HOMEBREW_LIBRARY}/Homebrew/cmd/shellenv.sh"
|
||||
homebrew-shellenv
|
||||
homebrew-shellenv "$1"
|
||||
exit 0
|
||||
;;
|
||||
formulae)
|
||||
|
@ -1,4 +1,4 @@
|
||||
#: * `shellenv`
|
||||
#: * `shellenv [bash|csh|fish|pwsh|sh|tcsh|zsh]`
|
||||
#:
|
||||
#: Print export statements. When run in a shell, this installation of Homebrew will be added to your `PATH`, `MANPATH`, and `INFOPATH`.
|
||||
#:
|
||||
@ -6,6 +6,8 @@
|
||||
#: To help guarantee idempotence, this command produces no output when Homebrew's `bin` and `sbin` directories are first and second
|
||||
#: respectively in your `PATH`. Consider adding evaluation of this command's output to your dotfiles (e.g. `~/.profile`,
|
||||
#: `~/.bash_profile`, or `~/.zprofile`) with: `eval "$(brew shellenv)"`
|
||||
#:
|
||||
#: The shell can be specified explicitly with a supported shell name parameter. Unknown shells will output POSIX exports.
|
||||
|
||||
# HOMEBREW_CELLAR and HOMEBREW_PREFIX are set by extend/ENV/super.rb
|
||||
# HOMEBREW_REPOSITORY is set by bin/brew
|
||||
@ -18,7 +20,14 @@ homebrew-shellenv() {
|
||||
return
|
||||
fi
|
||||
|
||||
case "$(/bin/ps -p "${PPID}" -c -o comm=)" in
|
||||
if [[ -n "$1" ]]
|
||||
then
|
||||
HOMEBREW_SHELL_NAME="$1"
|
||||
else
|
||||
HOMEBREW_SHELL_NAME="$(/bin/ps -p "${PPID}" -c -o comm=)}"
|
||||
fi
|
||||
|
||||
case "${HOMEBREW_SHELL_NAME}" in
|
||||
fish | -fish)
|
||||
echo "set -gx HOMEBREW_PREFIX \"${HOMEBREW_PREFIX}\";"
|
||||
echo "set -gx HOMEBREW_CELLAR \"${HOMEBREW_CELLAR}\";"
|
||||
|
Loading…
x
Reference in New Issue
Block a user