mirror of https://github.com/jenv/jenv.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.1 KiB
48 lines
1.1 KiB
#!/usr/bin/env bash |
|
# |
|
# Summary: Run an executable with the selected Ruby version |
|
# |
|
# Usage: jenv exec <command> [arg1 arg2...] |
|
# |
|
# Runs an executable by first preparing PATH so that the selected Ruby |
|
# version's `bin' directory is at the front. |
|
# |
|
# For example, if the currently selected Ruby version is 1.9.3-p327: |
|
# jenv exec bundle install |
|
# |
|
# is equivalent to: |
|
# PATH="$JENV_ROOT/versions/1.9.3-p327/bin:$PATH" bundle install |
|
|
|
set -e |
|
[ -n "$JENV_DEBUG" ] && set -x |
|
|
|
# Provide jenv completions |
|
if [ "$1" = "--complete" ]; then |
|
exec jenv shims --short |
|
fi |
|
|
|
export JENV_VERSION="$(jenv-version-name)" |
|
JENV_COMMAND="$1" |
|
|
|
export JAVA_HOME="$JENV_ROOT/versions/$JENV_VERSION" |
|
|
|
echo "java home : $JAVA_HOME" |
|
|
|
if [ -z "$JENV_COMMAND" ]; then |
|
jenv-help --usage exec >&2 |
|
exit 1 |
|
fi |
|
|
|
JENV_COMMAND_PATH="$(jenv-which "$JENV_COMMAND")" |
|
JENV_BIN_PATH="${JENV_COMMAND_PATH%/*}" |
|
|
|
|
|
for script in $(jenv-hooks exec); do |
|
source "$script" |
|
done |
|
|
|
shift 1 |
|
if [ "$JENV_VERSION" != "system" ]; then |
|
export PATH="${JENV_BIN_PATH}:${PATH}" |
|
fi |
|
exec -a "$JENV_COMMAND" "$JENV_COMMAND_PATH" "$@"
|
|
|