Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not rely on /usr/bin/env in critical paths #1483

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions libexec/rbenv-exec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if [ "$1" = "--complete" ]; then
exec rbenv-shims --short
fi

RBENV_VERSION="$(rbenv-version-name)"
RBENV_VERSION="$($BASH rbenv-version-name)"
RBENV_COMMAND="$1"

if [ -z "$RBENV_COMMAND" ]; then
Expand All @@ -30,10 +30,10 @@ if [ -z "$RBENV_COMMAND" ]; then
fi

export RBENV_VERSION
RBENV_COMMAND_PATH="$(rbenv-which "$RBENV_COMMAND")"
RBENV_COMMAND_PATH="$($BASH rbenv-which "$RBENV_COMMAND")"
RBENV_BIN_PATH="${RBENV_COMMAND_PATH%/*}"

IFS=$'\n' read -d '' -r -a scripts <<<"$(rbenv-hooks exec)" || true
IFS=$'\n' read -d '' -r -a scripts <<<"$($BASH rbenv-hooks exec)" || true
for script in "${scripts[@]}"; do
# shellcheck disable=SC1090
source "$script"
Expand Down
4 changes: 2 additions & 2 deletions libexec/rbenv-prefix
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ fi
if [ -n "$1" ]; then
export RBENV_VERSION="$1"
elif [ -z "$RBENV_VERSION" ]; then
RBENV_VERSION="$(rbenv-version-name)"
RBENV_VERSION="$($BASH rbenv-version-name)"
fi

if [ "$RBENV_VERSION" = "system" ]; then
if RUBY_PATH="$(rbenv-which ruby)"; then
if RUBY_PATH="$($BASH rbenv-which ruby)"; then
RUBY_PATH="${RUBY_PATH%/*}"
RBENV_PREFIX_PATH="${RUBY_PATH%/bin}"
echo "${RBENV_PREFIX_PATH:-/}"
Expand Down
8 changes: 4 additions & 4 deletions libexec/rbenv-version-name
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ set -e
[ -n "$RBENV_DEBUG" ] && set -x

if [ -z "$RBENV_VERSION" ]; then
RBENV_VERSION_FILE="$(rbenv-version-file)"
RBENV_VERSION="$(rbenv-version-file-read "$RBENV_VERSION_FILE" || true)"
RBENV_VERSION_FILE="$($BASH rbenv-version-file)"
RBENV_VERSION="$($BASH rbenv-version-file-read "$RBENV_VERSION_FILE" || true)"
fi

IFS=$'\n' read -d '' -r -a scripts <<<"$(rbenv-hooks version-name)" || true
IFS=$'\n' read -d '' -r -a scripts <<<"$($BASH rbenv-hooks version-name)" || true
for script in "${scripts[@]}"; do
# shellcheck disable=SC1090
source "$script"
Expand All @@ -29,6 +29,6 @@ if version_exists "$RBENV_VERSION"; then
elif version_exists "${RBENV_VERSION#ruby-}"; then
echo "${RBENV_VERSION#ruby-}"
else
echo "rbenv: version \`$RBENV_VERSION' is not installed (set by $(rbenv-version-origin))" >&2
echo "rbenv: version \`$RBENV_VERSION' is not installed (set by $($BASH rbenv-version-origin))" >&2
exit 1
fi
4 changes: 2 additions & 2 deletions libexec/rbenv-version-origin
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e

unset RBENV_VERSION_ORIGIN

IFS=$'\n' read -d '' -r -a scripts <<<"$(rbenv-hooks version-origin)" || true
IFS=$'\n' read -d '' -r -a scripts <<<"$($BASH rbenv-hooks version-origin)" || true
for script in "${scripts[@]}"; do
# shellcheck disable=SC1090
source "$script"
Expand All @@ -16,5 +16,5 @@ if [ -n "$RBENV_VERSION_ORIGIN" ]; then
elif [ -n "$RBENV_VERSION" ]; then
echo "RBENV_VERSION environment variable"
else
rbenv-version-file
$BASH rbenv-version-file
fi
4 changes: 2 additions & 2 deletions libexec/rbenv-whence
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ fi

whence() {
local command="$1"
rbenv-versions --bare | while read -r version; do
path="$(rbenv-prefix "$version")/bin/${command}"
$BASH rbenv-versions --bare | while read -r version; do
path="$($BASH rbenv-prefix "$version")/bin/${command}"
if [ -x "$path" ]; then
[ "$print_paths" ] && echo "$path" || echo "$version"
fi
Expand Down
8 changes: 4 additions & 4 deletions libexec/rbenv-which
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if [ -z "$RBENV_COMMAND" ]; then
exit 1
fi

RBENV_VERSION="${RBENV_VERSION:-$(rbenv-version-name)}"
RBENV_VERSION="${RBENV_VERSION:-$($BASH rbenv-version-name)}"

if [ "$RBENV_VERSION" = "system" ]; then
PATH="$(remove_from_path "${RBENV_ROOT}/shims")" \
Expand All @@ -47,7 +47,7 @@ if [[ ! -x "$RBENV_COMMAND_PATH" && -n "$GEM_HOME" && -x "${GEM_HOME}/bin/${RBEN
RBENV_COMMAND_PATH="${GEM_HOME}/bin/${RBENV_COMMAND}"
fi

IFS=$'\n' read -d '' -r -a scripts <<<"$(rbenv-hooks which)" || true
IFS=$'\n' read -d '' -r -a scripts <<<"$($BASH rbenv-hooks which)" || true
for script in "${scripts[@]}"; do
# shellcheck disable=SC1090
source "$script"
Expand All @@ -56,12 +56,12 @@ done
if [ -x "$RBENV_COMMAND_PATH" ]; then
echo "$RBENV_COMMAND_PATH"
elif [ "$RBENV_VERSION" != "system" ] && [ ! -d "${RBENV_ROOT}/versions/${RBENV_VERSION}" ]; then
echo "rbenv: version \`$RBENV_VERSION' is not installed (set by $(rbenv-version-origin))" >&2
echo "rbenv: version \`$RBENV_VERSION' is not installed (set by $($BASH rbenv-version-origin))" >&2
exit 1
else
echo "rbenv: $RBENV_COMMAND: command not found" >&2

versions="$(rbenv-whence "$RBENV_COMMAND" || true)"
versions="$($BASH rbenv-whence "$RBENV_COMMAND" || true)"
if [ -n "$versions" ]; then
{ echo
echo "The \`$1' command exists in these Ruby versions:"
Expand Down