Merge pull request #11246 from hyuraku/cmd_repair-style

Cmd repair style
This commit is contained in:
Mike McQuaid 2021-04-28 13:06:48 +01:00 committed by GitHub
commit d6efa5a76a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 28 deletions

View File

@ -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 ;;

View File

@ -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
}

View File

@ -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'

View File

@ -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
}