commit f55a9c80b1608b15710db58b09018656ad95c791 Author: Gildas Cuisinier Date: Thu Jan 24 23:50:08 2013 +0100 First commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/bin/jenv b/bin/jenv new file mode 120000 index 0000000..b938806 --- /dev/null +++ b/bin/jenv @@ -0,0 +1 @@ +../libexec/jenv \ No newline at end of file diff --git a/completions/jenv.bash b/completions/jenv.bash new file mode 100644 index 0000000..b91677b --- /dev/null +++ b/completions/jenv.bash @@ -0,0 +1,14 @@ +_jenv() { + COMPREPLY=() + local word="${COMP_WORDS[COMP_CWORD]}" + + if [ "$COMP_CWORD" -eq 1 ]; then + COMPREPLY=( $(compgen -W "$(jenv commands)" -- "$word") ) + else + local command="${COMP_WORDS[1]}" + local completions="$(jenv completions "$command")" + COMPREPLY=( $(compgen -W "$completions" -- "$word") ) + fi +} + +complete -F _jenv jenv diff --git a/completions/jenv.zsh b/completions/jenv.zsh new file mode 100644 index 0000000..ede3e10 --- /dev/null +++ b/completions/jenv.zsh @@ -0,0 +1,19 @@ +if [[ ! -o interactive ]]; then + return +fi + +compctl -K _jenv jenv + +_jenv() { + local word words completions + read -cA words + word="${words[2]}" + + if [ "${#words}" -eq 2 ]; then + completions="$(jenv commands)" + else + completions="$(jenv completions "${word}")" + fi + + reply=("${(ps:\n:)completions}") +} diff --git a/libexec/jenv b/libexec/jenv new file mode 100755 index 0000000..b83d305 --- /dev/null +++ b/libexec/jenv @@ -0,0 +1,80 @@ +#!/usr/bin/env bash +set -e +[ -n "$JENV_DEBUG" ] && set -x + +resolve_link() { + $(type -p greadlink readlink | head -1) "$1" +} + +abs_dirname() { + local cwd="$(pwd)" + local path="$1" + + while [ -n "$path" ]; do + cd "${path%/*}" + local name="${path##*/}" + path="$(resolve_link "$name" || true)" + done + + pwd + cd "$cwd" +} + +if [ -z "${JENV_ROOT}" ]; then + JENV_ROOT="${HOME}/.jenv" +else + JENV_ROOT="${JENV_ROOT%/}" +fi +export JENV_ROOT + +if [ -z "${JENV_DIR}" ]; then + JENV_DIR="$(pwd)" +else + cd "$JENV_DIR" 2>/dev/null || { + echo "jenv: cannot change working directory to \`$JENV_DIR'" + exit 1 + } >&2 + JENV_DIR="$(pwd)" + cd "$OLDPWD" +fi +export JENV_DIR + + +shopt -s nullglob + + + +bin_path="$(abs_dirname "$0")" +for plugin_bin in "${JENV_ROOT}/plugins/"*/bin; do + bin_path="${bin_path}:${plugin_bin}" +done +export PATH="${bin_path}:${PATH}" + +hook_path="${JENV_HOOK_PATH}" +for plugin_hook in "${JENV_ROOT}/plugins/"*/etc/jenv.d; do + hook_path="${hook_path}:${plugin_hook}" +done + +export JENV_HOOK_PATH=$hook_path + + + +shopt -u nullglob + + +command="$1" +case "$command" in +"" | "-h" | "--help" ) + echo -e "jenv 0.1.0\n$(jenv-help)" >&2 + ;; +* ) + command_path="$(command -v "jenv-$command" || true)" + if [ -z "$command_path" ]; then + echo "jenv: no such command \`$command'" >&2 + exit 1 + fi + + shift 1 + exec "$command_path" "$@" + ;; +esac diff --git a/libexec/jenv-add b/libexec/jenv-add new file mode 100755 index 0000000..3dc1040 --- /dev/null +++ b/libexec/jenv-add @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +set -e +[ -n "$JENV_DEBUG" ] && set -x + +# Provide jenv completions +if [ "$1" = "--complete" ]; then + echo --unset + echo system + exec jenv-versions --bare +fi + +JENV_VERSION="$1" +JENV_JAVAPATH="$2" +JENV_VERSION_FILE=".jenv-version" + +echo $JENV_VERSION +echo $JENV_JAVAPATH + + + +if [ -f "$JENV_JAVAPATH/bin/java" ]; +then + ln -s "$JENV_JAVAPATH" "${JENV_ROOT}/versions/$JENV_VERSION" +else + echo "$JENV_JAVAPATH is not a valid path to java installation" +fi diff --git a/libexec/jenv-commands b/libexec/jenv-commands new file mode 100755 index 0000000..6ebd301 --- /dev/null +++ b/libexec/jenv-commands @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +set -e +[ -n "$JENV_DEBUG" ] && set -x + +# Provide jenv completions +if [ "$1" = "--complete" ]; then + echo --sh + echo --no-sh + exit +fi + +if [ "$1" = "--sh" ]; then + sh=1 + shift +elif [ "$1" = "--no-sh" ]; then + nosh=1 + shift +fi + +shopt -s nullglob + +{ for path in ${PATH//:/$'\n'}; do + for command in "${path}/jenv-"*; do + command="${command##*jenv-}" + if [ -n "$sh" ]; then + if [ ${command:0:3} = "sh-" ]; then + echo ${command##sh-} + fi + elif [ -n "$nosh" ]; then + if [ ${command:0:3} != "sh-" ]; then + echo ${command##sh-} + fi + else + echo ${command##sh-} + fi + done + done +} | sort | uniq diff --git a/libexec/jenv-completions b/libexec/jenv-completions new file mode 100755 index 0000000..0c8f2da --- /dev/null +++ b/libexec/jenv-completions @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -e +[ -n "$JENV_DEBUG" ] && set -x + +COMMAND="$1" +if [ -z "$COMMAND" ]; then + echo "usage: jenv completions COMMAND [arg1 arg2...]" >&2 + exit 1 +fi + +COMMAND_PATH="$(command -v "jenv-$COMMAND" || command -v "jenv-sh-$COMMAND")" +if grep -i "^# provide jenv completions" "$COMMAND_PATH" >/dev/null; then + shift + exec "$COMMAND_PATH" --complete "$@" +fi diff --git a/libexec/jenv-exec b/libexec/jenv-exec new file mode 100755 index 0000000..7c65406 --- /dev/null +++ b/libexec/jenv-exec @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +set -e +[ -n "$JENV_DEBUG" ] && set -x + +# Provide jenv completions +if [ "$1" = "--complete" ]; then + exec jenv shims --short +fi + +export JAVA_HOME="${JENV_ROOT}/versions/$(jenv-version-name)" + +JENV_COMMAND="$1" +if [ -z "$JENV_COMMAND" ]; then + echo "usage: jenv exec COMMAND [arg1 arg2...]" >&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 +export PATH="${JENV_BIN_PATH}:${PATH}" +echo $PATH +exec -a "$JENV_COMMAND" "$JENV_COMMAND_PATH" "$@" diff --git a/libexec/jenv-global b/libexec/jenv-global new file mode 100755 index 0000000..19b34d2 --- /dev/null +++ b/libexec/jenv-global @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +set -e +[ -n "$JENV_DEBUG" ] && set -x + +# Provide jenv completions +if [ "$1" = "--complete" ]; then + echo system + exec jenv-versions --bare +fi + +JENV_VERSION="$1" +JENV_VERSION_FILE="${JENV_ROOT}/version" + +if [ -n "$JENV_VERSION" ]; then + jenv-version-file-write "$JENV_VERSION_FILE" "$JENV_VERSION" +else + jenv-version-file-read "$JENV_VERSION_FILE" || + jenv-version-file-read "${JENV_ROOT}/global" || + jenv-version-file-read "${JENV_ROOT}/default" || + echo system +fi diff --git a/libexec/jenv-help b/libexec/jenv-help new file mode 100755 index 0000000..e696646 --- /dev/null +++ b/libexec/jenv-help @@ -0,0 +1,88 @@ +#!/usr/bin/env bash +set -e +[ -n "$JENV_DEBUG" ] && set -x + +print_set_version() { + echo " should be a string matching a Ruby version known by jenv." + + local versions="$(jenv-versions --bare)" + if [ -z "$versions" ]; then + echo "There are currently no Ruby versions installed for jenv." + else + echo "The currently installed Ruby versions are:" + echo "$versions" | sed 's/^/ /' + fi + + echo + echo "The special version string 'system' will use your default system Ruby." +} + +case "$1" in +"") echo "usage: jenv [] + +Some useful jenv commands are: + commands List all jenv commands + rehash Rehash jenv shims (run this after installing binaries) + global Set or show the global Ruby version + local Set or show the local directory-specific Ruby version + shell Set or show the shell-specific Ruby version + version Show the current Ruby version + versions List all Ruby versions known by jenv + which Show the full path for the given Ruby command + whence List all Ruby versions with the given command + +See 'jenv help ' for information on a specific command. +For full documentation, see: https://github.com/sstephenson/jenv#readme" +;; +global) echo "usage: jenv global + +Sets the global Ruby version. You can override the global version at +any time by setting a directory-specific version with \`jenv local' +or by setting the JENV_VERSION environment variable. + +$(print_set_version)" +;; +local) echo "usage: jenv local + jenv local --unset + +Sets the local directory-specific Ruby version by writing the version +name to a file named '.jenv-version'. + +When you run a Ruby command, jenv will look for an '.jenv-version' +file in the current directory and each parent directory. If no such +file is found in the tree, jenv will use the global Ruby version +specified with \`jenv global', or the version specified in the +JENV_VERSION environment variable. + +$(print_set_version)" +;; +shell) echo "usage: jenv shell + jenv shell --unset + +Sets a shell-specific Ruby version by setting the 'JENV_VERSION' +environment variable in your shell. This version overrides both +project-specific versions and the global version. + +$(print_set_version)" +;; +which) echo "usage: jenv which + +Displays the full path to the binary that jenv will execute when you +run the given command." +;; +whence) echo "usage: jenv whence + +Lists all Ruby versions with the given command installed." +;; +*) + command_path="$(command -v "jenv-$1" || true)" + if [ -n "$command_path" ]; then + echo "Sorry, the \`$1' command isn't documented yet." + echo + echo "You can view the command's source here:" + echo "$command_path" + echo + else + echo "jenv: no such command \`$1'" + fi +esac diff --git a/libexec/jenv-hooks b/libexec/jenv-hooks new file mode 100755 index 0000000..90c4659 --- /dev/null +++ b/libexec/jenv-hooks @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +set -e +[ -n "$JENV_DEBUG" ] && set -x + +# Provide jenv completions +if [ "$1" = "--complete" ]; then + echo exec + echo rehash + echo which + exit +fi + +JENV_COMMAND="$1" +if [ -z "$JENV_COMMAND" ]; then + echo "usage: jenv hooks COMMAND" >&2 + exit 1 +fi + +resolve_link() { + $(type -p greadlink readlink | head -1) $1 +} + +realpath() { + local cwd="$(pwd)" + local base="$(basename $1)" + local path="$1" + + while [ -n "$path" ]; do + cd "${path%/*}" + local name="${path##*/}" + path="$(resolve_link "$name" || true)" + done + + echo "$(pwd)/$base" + cd "$cwd" +} + +shopt -s nullglob +for path in ${JENV_HOOK_PATH//:/$'\n'}; do + for script in $path/"$JENV_COMMAND"/*.bash; do + echo $(realpath $script) + done +done +shopt -u nullglob diff --git a/libexec/jenv-init b/libexec/jenv-init new file mode 100755 index 0000000..253f605 --- /dev/null +++ b/libexec/jenv-init @@ -0,0 +1,98 @@ +#!/usr/bin/env bash +set -e +[ -n "$JENV_DEBUG" ] && set -x + +print="" +if [ "$1" = "-" ]; then + print=1 + shift +fi + +no_rehash="" +if [ "$1" = "--no-rehash" ]; then + no_rehash=1 + shift +fi + +shell="$1" +if [ -z "$shell" ]; then + shell="$(basename "$SHELL")" +fi + +resolve_link() { + $(type -p greadlink readlink | head -1) $1 +} + +abs_dirname() { + local cwd="$(pwd)" + local path="$1" + + while [ -n "$path" ]; do + cd "${path%/*}" + local name="${path##*/}" + path="$(resolve_link "$name" || true)" + done + + pwd + cd "$cwd" +} + +root="$(abs_dirname "$0")/.." + +if [ -z "$print" ]; then + case "$shell" in + bash ) + profile='~/.bash_profile' + ;; + zsh ) + profile='~/.zshrc' + ;; + ksh ) + profile='~/.profile' + ;; + * ) + profile='your profile' + ;; + esac + + { echo "# Load jenv automatically by adding" + echo "# the following to ${profile}:" + echo + echo 'eval "$(jenv init -)"' + echo + } >&2 + + exit 1 +fi + +mkdir -p "${JENV_ROOT}/"{shims,versions} + +echo 'export PATH="'${JENV_ROOT}'/shims:${PATH}"' + +case "$shell" in +bash | zsh ) + echo "source \"$root/completions/jenv.${shell}\"" + ;; +esac + +if [ -z "$no_rehash" ]; then + echo 'jenv rehash 2>/dev/null' +fi + +commands=(`jenv commands --sh`) +IFS="|" +cat <&2 +fi diff --git a/libexec/jenv-prefix b/libexec/jenv-prefix new file mode 100755 index 0000000..90726ae --- /dev/null +++ b/libexec/jenv-prefix @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +set -e +[ -n "$JENV_DEBUG" ] && set -x + +# Provide jenv completions +if [ "$1" = "--complete" ]; then + echo system + exec jenv-versions --bare +fi + +if [ -n "$1" ]; then + export JENV_VERSION="$1" +elif [ -z "$JENV_VERSION" ]; then + JENV_VERSION="$(jenv-version-name)" +fi + +if [ "$JENV_VERSION" = "system" ]; then + RUBY_PATH="$(jenv-which ruby)" + echo "${RUBY_PATH%/*}" + exit +fi + +JENV_PREFIX_PATH="${JENV_ROOT}/versions/${JENV_VERSION}" +if [ ! -d "$JENV_PREFIX_PATH" ]; then + echo "jenv: version \`${JENV_VERSION}' not installed" >&2 + exit 1 +fi + +echo "$JENV_PREFIX_PATH" diff --git a/libexec/jenv-rehash b/libexec/jenv-rehash new file mode 100755 index 0000000..75776e1 --- /dev/null +++ b/libexec/jenv-rehash @@ -0,0 +1,149 @@ +#!/usr/bin/env bash +set -e +[ -n "$JENV_DEBUG" ] && set -x + +SHIM_PATH="${JENV_ROOT}/shims" +PROTOTYPE_SHIM_PATH="${SHIM_PATH}/.jenv-shim" + +# Create the shims directory if it doesn't already exist. +mkdir -p "$SHIM_PATH" + +# Ensure only one instance of jenv-rehash is running at a time by +# setting the shell's `noclobber` option and attempting to write to +# the prototype shim file. If the file already exists, print a warning +# to stderr and exit with a non-zero status. +set -o noclobber +{ echo > "$PROTOTYPE_SHIM_PATH" +} 2>/dev/null || +{ echo "jenv: cannot rehash: $PROTOTYPE_SHIM_PATH exists" + exit 1 +} >&2 +set +o noclobber + +# If we were able to obtain a lock, register a trap to clean up the +# prototype shim when the process exits. +trap remove_prototype_shim EXIT + +remove_prototype_shim() { + rm -f "$PROTOTYPE_SHIM_PATH" +} + +# The prototype shim file is a script that re-execs itself, passing +# its filename and any arguments to `jenv exec`. This file is +# hard-linked for every binary and then removed. The linking technique +# is fast, uses less disk space than unique files, and also serves as +# a locking mechanism. +create_prototype_shim() { + cat > "$PROTOTYPE_SHIM_PATH" <&2 + exit 1 + else + echo "echo \"\$JENV_VERSION\"" + exit + fi +fi + +if [ "$version" = "--unset" ]; then + echo "unset JENV_VERSION" + exit 1 +fi + +# Make sure the specified version is installed. +jenv-prefix "$version" >/dev/null + +echo "export JENV_VERSION=\"${version}\"" diff --git a/libexec/jenv-shims b/libexec/jenv-shims new file mode 100755 index 0000000..8887104 --- /dev/null +++ b/libexec/jenv-shims @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +set -e +[ -n "$JENV_DEBUG" ] && set -x + +# Provide jenv completions +if [ "$1" = "--complete" ]; then + echo --short + exit +fi + +for command in "${JENV_ROOT}/shims/"*; do + if [ "$1" = "--short" ]; then + echo "${command##*/}" + else + echo "$command" + fi +done | sort diff --git a/libexec/jenv-version b/libexec/jenv-version new file mode 100755 index 0000000..deb7627 --- /dev/null +++ b/libexec/jenv-version @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -e +[ -n "$JENV_DEBUG" ] && set -x + +echo "$(jenv-version-name) (set by $(jenv-version-origin))" diff --git a/libexec/jenv-version-file b/libexec/jenv-version-file new file mode 100755 index 0000000..2328593 --- /dev/null +++ b/libexec/jenv-version-file @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +set -e +[ -n "$JENV_DEBUG" ] && set -x + +root="$JENV_DIR" +while [ -n "$root" ]; do + if [ -e "${root}/.jenv-version" ]; then + echo "${root}/.jenv-version" + exit + fi + root="${root%/*}" +done + +global_version_file="${JENV_ROOT}/version" + +if [ -e "$global_version_file" ]; then + echo "$global_version_file" +elif [ -e "${JENV_ROOT}/global" ]; then + echo "${JENV_ROOT}/global" +elif [ -e "${JENV_ROOT}/default" ]; then + echo "${JENV_ROOT}/default" +else + echo "$global_version_file" +fi diff --git a/libexec/jenv-version-file-read b/libexec/jenv-version-file-read new file mode 100755 index 0000000..13c55e0 --- /dev/null +++ b/libexec/jenv-version-file-read @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +set -e +[ -n "$JENV_DEBUG" ] && set -x + +VERSION_FILE="$1" + +if [ -e "$VERSION_FILE" ]; then + # Read and print the first non-whitespace word from the specified + # version file. + version="" + while read -a words; do + word="${words[0]}" + if [ -z "$version" ] && [ -n "$word" ]; then + version="$word" + fi + done < <( cat "$VERSION_FILE" && echo ) + + if [ -n "$version" ]; then + echo "$version" + exit + fi +fi + +exit 1 diff --git a/libexec/jenv-version-file-write b/libexec/jenv-version-file-write new file mode 100755 index 0000000..62bfe48 --- /dev/null +++ b/libexec/jenv-version-file-write @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +set -e +[ -n "$JENV_DEBUG" ] && set -x + +JENV_VERSION_FILE="$1" +JENV_VERSION="$2" + +if [ -z "$JENV_VERSION" ] || [ -z "$JENV_VERSION_FILE" ]; then + echo "usage: jenv write-version-file FILENAME VERSION" >&2 + exit 1 +fi + +# Make sure the specified version is installed. +jenv-prefix "$JENV_VERSION" >/dev/null + +# Write the version out to disk. +echo "$JENV_VERSION" > "$JENV_VERSION_FILE" diff --git a/libexec/jenv-version-name b/libexec/jenv-version-name new file mode 100755 index 0000000..2ce8b96 --- /dev/null +++ b/libexec/jenv-version-name @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -e +[ -n "$JENV_DEBUG" ] && set -x + +if [ -z "$JENV_VERSION" ]; then + JENV_VERSION_FILE="$(jenv-version-file)" + JENV_VERSION="$(jenv-version-file-read "$JENV_VERSION_FILE" || true)" +fi + +if [ -z "$JENV_VERSION" ] || [ "$JENV_VERSION" = "system" ]; then + echo "system" + exit +fi + +JENV_VERSION_PATH="${JENV_ROOT}/versions/${JENV_VERSION}" + +if [ -d "$JENV_VERSION_PATH" ]; then + echo "$JENV_VERSION" +else + echo "jenv: version \`$JENV_VERSION' is not installed" >&2 + exit 1 +fi diff --git a/libexec/jenv-version-origin b/libexec/jenv-version-origin new file mode 100755 index 0000000..6c1c1a0 --- /dev/null +++ b/libexec/jenv-version-origin @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +set -e +[ -n "$JENV_DEBUG" ] && set -x + +if [ -n "$JENV_VERSION" ]; then + echo "JENV_VERSION environment variable" +else + jenv-version-file +fi diff --git a/libexec/jenv-versions b/libexec/jenv-versions new file mode 100755 index 0000000..f71020b --- /dev/null +++ b/libexec/jenv-versions @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +set -e +[ -n "$JENV_DEBUG" ] && set -x + +JENV_VERSION_NAME="$(jenv-version-name)" + +if [ "$1" = "--bare" ]; then + hit_prefix="" + miss_prefix="" + print_version="$JENV_VERSION_NAME" +else + hit_prefix="* " + miss_prefix=" " + print_version="$(jenv-version)" +fi + +for path in "${JENV_ROOT}/versions/"*; do + if [ -d "$path" ]; then + version="${path##*/}" + + if [ "$version" == "$JENV_VERSION_NAME" ]; then + echo "${hit_prefix}${print_version}" + else + echo "${miss_prefix}${version}" + fi + fi +done diff --git a/libexec/jenv-whence b/libexec/jenv-whence new file mode 100755 index 0000000..a5cb4e2 --- /dev/null +++ b/libexec/jenv-whence @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +set -e +[ -n "$JENV_DEBUG" ] && set -x + +# Provide jenv completions +if [ "$1" = "--complete" ]; then + echo --path + exec jenv shims --short +fi + +if [ "$1" = "--path" ]; then + print_paths="1" + shift +else + print_paths="" +fi + +whence() { + local command="$1" + jenv-versions --bare | while read version; do + path="$(jenv-prefix "$version")/bin/${command}" + if [ -x "$path" ]; then + [ "$print_paths" ] && echo "$path" || echo "$version" + fi + done +} + +JENV_COMMAND="$1" +if [ -z "$JENV_COMMAND" ]; then + echo "usage: jenv whence [--path] COMMAND" >&2 + exit 1 +fi + +result="$(whence "$JENV_COMMAND")" +[ -n "$result" ] && echo "$result" diff --git a/libexec/jenv-which b/libexec/jenv-which new file mode 100755 index 0000000..aa86c0b --- /dev/null +++ b/libexec/jenv-which @@ -0,0 +1,83 @@ +#!/usr/bin/env bash +set -e +[ -n "$JENV_DEBUG" ] && set -x + +# Provide jenv completions +if [ "$1" = "--complete" ]; then + exec jenv shims --short +fi + +expand_path() { + if [ ! -d "$1" ]; then + return 1 + fi + + local cwd="$(pwd)" + cd "$1" + pwd + cd "$cwd" +} + +remove_from_path() { + local path_to_remove="$(expand_path "$1")" + local result="" + + if [ -z "$path_to_remove" ]; then + echo "${PATH}" + return + fi + + for path in ${PATH//:/$'\n'}; do + path="$(expand_path "$path" || true)" + if [ -n "$path" ] && [ "$path" != "$path_to_remove" ]; then + result="${result}${path}:" + fi + done + + echo "${result%:}" +} + +JENV_VERSION="$(jenv-version-name)" +JENV_COMMAND="$1" + +if [ -z "$JENV_COMMAND" ]; then + echo "usage: jenv which COMMAND" >&2 + exit 1 +fi + +if [ "$JENV_VERSION" = "system" ]; then + PATH="$(remove_from_path "${JENV_ROOT}/shims")" + JENV_COMMAND_PATH="$(command -v "$JENV_COMMAND")" +else + JENV_COMMAND_PATH="${JENV_ROOT}/versions/${JENV_VERSION}/bin/${JENV_COMMAND}" + + if [ -x "$JENV_COMMAND_PATH" ]; then + echo + else + PATH="$(remove_from_path "${JENV_ROOT}/shims")" + JENV_COMMAND_PATH="$(command -v "$JENV_COMMAND")" + fi + + +fi + +for script in $(jenv-hooks which); do + source "$script" +done + +if [ -x "$JENV_COMMAND_PATH" ]; then + echo "$JENV_COMMAND_PATH" +else + echo "jenv: $JENV_COMMAND: command not found" >&2 + + versions="$(jenv-whence "$JENV_COMMAND" || true)" + if [ -n "$versions" ]; then + { echo + echo "The \`$1' command exists in these Ruby versions:" + echo "$versions" | sed 's/^/ /g' + echo + } >&2 + fi + + exit 127 +fi diff --git a/plugins/maven/etc/jenv.d/rehash/maven.bash b/plugins/maven/etc/jenv.d/rehash/maven.bash new file mode 100644 index 0000000..3623bed --- /dev/null +++ b/plugins/maven/etc/jenv.d/rehash/maven.bash @@ -0,0 +1,2 @@ +bin_path="/usr/share/maven/bin/*" +make_shims "$bin_path" \ No newline at end of file