mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
style: fix inconsistent code style for shell scripts
This commit is contained in:
parent
c2d5d84b21
commit
bd8db0737d
@ -74,7 +74,8 @@ esac
|
|||||||
# These variables are set from the user environment.
|
# These variables are set from the user environment.
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
ohai() {
|
ohai() {
|
||||||
if [[ -n "${HOMEBREW_COLOR}" || (-t 1 && -z "${HOMEBREW_NO_COLOR}") ]] # check whether stdout is a tty.
|
# Check whether stdout is a tty.
|
||||||
|
if [[ -n "${HOMEBREW_COLOR}" || (-t 1 && -z "${HOMEBREW_NO_COLOR}") ]]
|
||||||
then
|
then
|
||||||
echo -e "\\033[34m==>\\033[0m \\033[1m$*\\033[0m" # blue arrow and bold text
|
echo -e "\\033[34m==>\\033[0m \\033[1m$*\\033[0m" # blue arrow and bold text
|
||||||
else
|
else
|
||||||
@ -83,7 +84,8 @@ ohai() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
opoo() {
|
opoo() {
|
||||||
if [[ -n "${HOMEBREW_COLOR}" || (-t 2 && -z "${HOMEBREW_NO_COLOR}") ]] # check whether stderr is a tty.
|
# Check whether stderr is a tty.
|
||||||
|
if [[ -n "${HOMEBREW_COLOR}" || (-t 2 && -z "${HOMEBREW_NO_COLOR}") ]]
|
||||||
then
|
then
|
||||||
echo -ne "\\033[4;33mWarning\\033[0m: " >&2 # highlight Warning with underline and yellow color
|
echo -ne "\\033[4;33mWarning\\033[0m: " >&2 # highlight Warning with underline and yellow color
|
||||||
else
|
else
|
||||||
@ -98,7 +100,8 @@ opoo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bold() {
|
bold() {
|
||||||
if [[ -n "${HOMEBREW_COLOR}" || (-t 2 && -z "${HOMEBREW_NO_COLOR}") ]] # check whether stderr is a tty.
|
# Check whether stderr is a tty.
|
||||||
|
if [[ -n "${HOMEBREW_COLOR}" || (-t 2 && -z "${HOMEBREW_NO_COLOR}") ]]
|
||||||
then
|
then
|
||||||
echo -e "\\033[1m""$*""\\033[0m"
|
echo -e "\\033[1m""$*""\\033[0m"
|
||||||
else
|
else
|
||||||
@ -107,7 +110,8 @@ bold() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onoe() {
|
onoe() {
|
||||||
if [[ -n "${HOMEBREW_COLOR}" || (-t 2 && -z "${HOMEBREW_NO_COLOR}") ]] # check whether stderr is a tty.
|
# Check whether stderr is a tty.
|
||||||
|
if [[ -n "${HOMEBREW_COLOR}" || (-t 2 && -z "${HOMEBREW_NO_COLOR}") ]]
|
||||||
then
|
then
|
||||||
echo -ne "\\033[4;31mError\\033[0m: " >&2 # highlight Error with underline and red color
|
echo -ne "\\033[4;31mError\\033[0m: " >&2 # highlight Error with underline and red color
|
||||||
else
|
else
|
||||||
|
@ -10,8 +10,11 @@
|
|||||||
# HOMEBREW_REPOSITORY is set by bin/brew
|
# HOMEBREW_REPOSITORY is set by bin/brew
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
homebrew-shellenv() {
|
homebrew-shellenv() {
|
||||||
[[ "${HOMEBREW_SHELLENV_PREFIX}" == "${HOMEBREW_PREFIX}" ]] &&
|
if [[ "${HOMEBREW_SHELLENV_PREFIX}" == "${HOMEBREW_PREFIX}" ]] &&
|
||||||
[[ "$(PATH="${HOMEBREW_PATH}" command -v brew)" == "${HOMEBREW_PREFIX}/bin/brew" ]] && return
|
[[ "$(PATH="${HOMEBREW_PATH}" command -v brew)" == "${HOMEBREW_PREFIX}/bin/brew" ]]
|
||||||
|
then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
case "$(/bin/ps -p "${PPID}" -c -o comm=)" in
|
case "$(/bin/ps -p "${PPID}" -c -o comm=)" in
|
||||||
fish | -fish)
|
fish | -fish)
|
||||||
|
@ -650,7 +650,7 @@ EOS
|
|||||||
# shellcheck disable=SC2031
|
# shellcheck disable=SC2031
|
||||||
if [[ -n "${HOMEBREW_INSTALL_FROM_API}" ]] &&
|
if [[ -n "${HOMEBREW_INSTALL_FROM_API}" ]] &&
|
||||||
[[ -n "${HOMEBREW_UPDATE_PREINSTALL}" ]] &&
|
[[ -n "${HOMEBREW_UPDATE_PREINSTALL}" ]] &&
|
||||||
[[ "${DIR}" == "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core" || \
|
[[ "${DIR}" == "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core" ||
|
||||||
"${DIR}" == "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-cask" ]]
|
"${DIR}" == "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-cask" ]]
|
||||||
then
|
then
|
||||||
continue
|
continue
|
||||||
|
6
bin/brew
6
bin/brew
@ -2,13 +2,15 @@
|
|||||||
set +o posix
|
set +o posix
|
||||||
|
|
||||||
# Fail fast with concise message when cwd does not exist
|
# Fail fast with concise message when cwd does not exist
|
||||||
if ! [[ -d "${PWD}" ]]; then
|
if ! [[ -d "${PWD}" ]]
|
||||||
|
then
|
||||||
echo "Error: The current working directory doesn't exist, cannot proceed." >&2
|
echo "Error: The current working directory doesn't exist, cannot proceed." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Fail fast with concise message when not using bash
|
# Fail fast with concise message when not using bash
|
||||||
if [ -z "${BASH_VERSION:-}" ]; then
|
if [ -z "${BASH_VERSION:-}" ]
|
||||||
|
then
|
||||||
echo "Error: Bash is required to run brew." >&2
|
echo "Error: Bash is required to run brew." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user