Merge pull request #17500 from Homebrew/setup-ruby-ruby
cmd/setup-ruby: fix Portable Ruby install failing
This commit is contained in:
commit
bfd1b18e92
@ -167,95 +167,7 @@ esac
|
||||
#####
|
||||
##### Next, define all helper functions.
|
||||
#####
|
||||
|
||||
# These variables are set from the user environment.
|
||||
# shellcheck disable=SC2154
|
||||
ohai() {
|
||||
# Check whether stdout is a tty.
|
||||
if [[ -n "${HOMEBREW_COLOR}" || (-t 1 && -z "${HOMEBREW_NO_COLOR}") ]]
|
||||
then
|
||||
echo -e "\\033[34m==>\\033[0m \\033[1m$*\\033[0m" # blue arrow and bold text
|
||||
else
|
||||
echo "==> $*"
|
||||
fi
|
||||
}
|
||||
|
||||
opoo() {
|
||||
# Check whether stderr is a tty.
|
||||
if [[ -n "${HOMEBREW_COLOR}" || (-t 2 && -z "${HOMEBREW_NO_COLOR}") ]]
|
||||
then
|
||||
echo -ne "\\033[4;33mWarning\\033[0m: " >&2 # highlight Warning with underline and yellow color
|
||||
else
|
||||
echo -n "Warning: " >&2
|
||||
fi
|
||||
if [[ $# -eq 0 ]]
|
||||
then
|
||||
cat >&2
|
||||
else
|
||||
echo "$*" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
bold() {
|
||||
# Check whether stderr is a tty.
|
||||
if [[ -n "${HOMEBREW_COLOR}" || (-t 2 && -z "${HOMEBREW_NO_COLOR}") ]]
|
||||
then
|
||||
echo -e "\\033[1m""$*""\\033[0m"
|
||||
else
|
||||
echo "$*"
|
||||
fi
|
||||
}
|
||||
|
||||
onoe() {
|
||||
# Check whether stderr is a tty.
|
||||
if [[ -n "${HOMEBREW_COLOR}" || (-t 2 && -z "${HOMEBREW_NO_COLOR}") ]]
|
||||
then
|
||||
echo -ne "\\033[4;31mError\\033[0m: " >&2 # highlight Error with underline and red color
|
||||
else
|
||||
echo -n "Error: " >&2
|
||||
fi
|
||||
if [[ $# -eq 0 ]]
|
||||
then
|
||||
cat >&2
|
||||
else
|
||||
echo "$*" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
odie() {
|
||||
onoe "$@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
safe_cd() {
|
||||
cd "$@" >/dev/null || odie "Failed to cd to $*!"
|
||||
}
|
||||
|
||||
brew() {
|
||||
# This variable is set by bin/brew
|
||||
# shellcheck disable=SC2154
|
||||
"${HOMEBREW_BREW_FILE}" "$@"
|
||||
}
|
||||
|
||||
curl() {
|
||||
"${HOMEBREW_LIBRARY}/Homebrew/shims/shared/curl" "$@"
|
||||
}
|
||||
|
||||
git() {
|
||||
"${HOMEBREW_LIBRARY}/Homebrew/shims/shared/git" "$@"
|
||||
}
|
||||
|
||||
# Search given executable in PATH (remove dependency for `which` command)
|
||||
which() {
|
||||
# Alias to Bash built-in command `type -P`
|
||||
type -P "$@"
|
||||
}
|
||||
|
||||
numeric() {
|
||||
# Condense the exploded argument into a single return value.
|
||||
# shellcheck disable=SC2086,SC2183
|
||||
printf "%01d%02d%02d%03d" ${1//[.rc]/ } 2>/dev/null
|
||||
}
|
||||
source "${HOMEBREW_LIBRARY}/Homebrew/utils/helpers.sh"
|
||||
|
||||
check-run-command-as-root() {
|
||||
[[ "${EUID}" == 0 || "${UID}" == 0 ]] || return
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
# HOMEBREW_BREW_FILE is set by extend/ENV/super.rb
|
||||
# shellcheck disable=SC2154
|
||||
homebrew-setup-ruby() {
|
||||
source "${HOMEBREW_LIBRARY}/Homebrew/utils/helpers.sh"
|
||||
source "${HOMEBREW_LIBRARY}/Homebrew/utils/ruby.sh"
|
||||
setup-ruby-path
|
||||
|
||||
|
||||
88
Library/Homebrew/utils/helpers.sh
Normal file
88
Library/Homebrew/utils/helpers.sh
Normal file
@ -0,0 +1,88 @@
|
||||
# These variables are set from the user environment.
|
||||
# shellcheck disable=SC2154
|
||||
ohai() {
|
||||
# Check whether stdout is a tty.
|
||||
if [[ -n "${HOMEBREW_COLOR}" || (-t 1 && -z "${HOMEBREW_NO_COLOR}") ]]
|
||||
then
|
||||
echo -e "\\033[34m==>\\033[0m \\033[1m$*\\033[0m" # blue arrow and bold text
|
||||
else
|
||||
echo "==> $*"
|
||||
fi
|
||||
}
|
||||
|
||||
opoo() {
|
||||
# Check whether stderr is a tty.
|
||||
if [[ -n "${HOMEBREW_COLOR}" || (-t 2 && -z "${HOMEBREW_NO_COLOR}") ]]
|
||||
then
|
||||
echo -ne "\\033[4;33mWarning\\033[0m: " >&2 # highlight Warning with underline and yellow color
|
||||
else
|
||||
echo -n "Warning: " >&2
|
||||
fi
|
||||
if [[ $# -eq 0 ]]
|
||||
then
|
||||
cat >&2
|
||||
else
|
||||
echo "$*" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
bold() {
|
||||
# Check whether stderr is a tty.
|
||||
if [[ -n "${HOMEBREW_COLOR}" || (-t 2 && -z "${HOMEBREW_NO_COLOR}") ]]
|
||||
then
|
||||
echo -e "\\033[1m""$*""\\033[0m"
|
||||
else
|
||||
echo "$*"
|
||||
fi
|
||||
}
|
||||
|
||||
onoe() {
|
||||
# Check whether stderr is a tty.
|
||||
if [[ -n "${HOMEBREW_COLOR}" || (-t 2 && -z "${HOMEBREW_NO_COLOR}") ]]
|
||||
then
|
||||
echo -ne "\\033[4;31mError\\033[0m: " >&2 # highlight Error with underline and red color
|
||||
else
|
||||
echo -n "Error: " >&2
|
||||
fi
|
||||
if [[ $# -eq 0 ]]
|
||||
then
|
||||
cat >&2
|
||||
else
|
||||
echo "$*" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
odie() {
|
||||
onoe "$@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
safe_cd() {
|
||||
cd "$@" >/dev/null || odie "Failed to cd to $*!"
|
||||
}
|
||||
|
||||
brew() {
|
||||
# This variable is set by bin/brew
|
||||
# shellcheck disable=SC2154
|
||||
"${HOMEBREW_BREW_FILE}" "$@"
|
||||
}
|
||||
|
||||
curl() {
|
||||
"${HOMEBREW_LIBRARY}/Homebrew/shims/shared/curl" "$@"
|
||||
}
|
||||
|
||||
git() {
|
||||
"${HOMEBREW_LIBRARY}/Homebrew/shims/shared/git" "$@"
|
||||
}
|
||||
|
||||
# Search given executable in PATH (remove dependency for `which` command)
|
||||
which() {
|
||||
# Alias to Bash built-in command `type -P`
|
||||
type -P "$@"
|
||||
}
|
||||
|
||||
numeric() {
|
||||
# Condense the exploded argument into a single return value.
|
||||
# shellcheck disable=SC2086,SC2183
|
||||
printf "%01d%02d%02d%03d" ${1//[.rc]/ } 2>/dev/null
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user