diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index 5fbb120346..d7d6f8b2f2 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -315,6 +315,7 @@ then fi HOMEBREW_CORE_REPOSITORY="${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core" +HOMEBREW_CASK_REPOSITORY="${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-cask" case "$*" in --version|-v) source "${HOMEBREW_LIBRARY}/Homebrew/cmd/--version.sh"; homebrew-version; exit 0 ;; diff --git a/Library/Homebrew/cmd/--version.sh b/Library/Homebrew/cmd/--version.sh index c1d92a7a0d..bcd2d21264 100644 --- a/Library/Homebrew/cmd/--version.sh +++ b/Library/Homebrew/cmd/--version.sh @@ -2,30 +2,32 @@ #: #: Print the version numbers of Homebrew, Homebrew/homebrew-core and Homebrew/homebrew-cask (if tapped) to standard output. +# HOMEBREW_CORE_REPOSITORY, HOMEBREW_CASK_REPOSITORY, HOMEBREW_VERSION are set by brew.sh +# shellcheck disable=SC2154 version_string() { local repo="$1" - if ! [ -d "$repo" ]; then + if ! [ -d "${repo}" ]; then echo "N/A" return fi local pretty_revision - pretty_revision="$(git -C "$repo" rev-parse --short --verify --quiet HEAD)" - if [ -z "$pretty_revision" ]; then + pretty_revision="$(git -C "${repo}" rev-parse --short --verify --quiet HEAD)" + if [ -z "${pretty_revision}" ]; then echo "(no Git repository)" return fi local git_last_commit_date - git_last_commit_date=$(git -C "$repo" show -s --format='%cd' --date=short HEAD) + git_last_commit_date=$(git -C "${repo}" show -s --format='%cd' --date=short HEAD) echo "(git revision ${pretty_revision}; last commit ${git_last_commit_date})" } homebrew-version() { - echo "Homebrew $HOMEBREW_VERSION" - echo "Homebrew/homebrew-core $(version_string "$HOMEBREW_CORE_REPOSITORY")" + echo "Homebrew ${HOMEBREW_VERSION}" + echo "Homebrew/homebrew-core $(version_string "${HOMEBREW_CORE_REPOSITORY}")" - if [ -d "$HOMEBREW_CASK_REPOSITORY" ]; then - echo "Homebrew/homebrew-cask $(version_string "$HOMEBREW_CASK_REPOSITORY")" + if [ -d "${HOMEBREW_CASK_REPOSITORY}" ]; then + echo "Homebrew/homebrew-cask $(version_string "${HOMEBREW_CASK_REPOSITORY}")" fi } diff --git a/Library/Homebrew/cmd/casks.sh b/Library/Homebrew/cmd/casks.sh index 4a8d866f45..aa3a75cf2b 100644 --- a/Library/Homebrew/cmd/casks.sh +++ b/Library/Homebrew/cmd/casks.sh @@ -3,7 +3,9 @@ #: List all locally installable casks including short names. #: -source "$HOMEBREW_LIBRARY/Homebrew/items.sh" +# HOMEBREW_LIBRARY is set in bin/brew +# shellcheck disable=SC2154 +source "${HOMEBREW_LIBRARY}/Homebrew/items.sh" homebrew-casks() { homebrew-items 'Formula' 's|/Casks/|/|' '^homebrew/cask' diff --git a/Library/Homebrew/cmd/shellenv.sh b/Library/Homebrew/cmd/shellenv.sh index 39327d20fc..d7f2e73972 100644 --- a/Library/Homebrew/cmd/shellenv.sh +++ b/Library/Homebrew/cmd/shellenv.sh @@ -5,31 +5,34 @@ #: The variables `HOMEBREW_PREFIX`, `HOMEBREW_CELLAR` and `HOMEBREW_REPOSITORY` are also exported to avoid querying them multiple times. #: 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() { - case "$(/bin/ps -p $PPID -c -o comm=)" in + 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 -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_PREFIX \"${HOMEBREW_PREFIX}\";" + echo "set -gx HOMEBREW_CELLAR \"${HOMEBREW_CELLAR}\";" + echo "set -gx HOMEBREW_REPOSITORY \"${HOMEBREW_REPOSITORY}\";" + 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;" ;; csh|-csh|tcsh|-tcsh) - echo "setenv HOMEBREW_PREFIX $HOMEBREW_PREFIX;" - echo "setenv HOMEBREW_CELLAR $HOMEBREW_CELLAR;" - echo "setenv HOMEBREW_REPOSITORY $HOMEBREW_REPOSITORY;" - 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_PREFIX ${HOMEBREW_PREFIX};" + echo "setenv HOMEBREW_CELLAR ${HOMEBREW_CELLAR};" + echo "setenv HOMEBREW_REPOSITORY ${HOMEBREW_REPOSITORY};" + 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 "export HOMEBREW_PREFIX=\"$HOMEBREW_PREFIX\";" - echo "export HOMEBREW_CELLAR=\"$HOMEBREW_CELLAR\";" - echo "export HOMEBREW_REPOSITORY=\"$HOMEBREW_REPOSITORY\";" - 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_PREFIX=\"${HOMEBREW_PREFIX}\";" + echo "export HOMEBREW_CELLAR=\"${HOMEBREW_CELLAR}\";" + echo "export HOMEBREW_REPOSITORY=\"${HOMEBREW_REPOSITORY}\";" + 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:-}\";" ;; esac }