|
|
|
|
@ -1,6 +1,11 @@
@@ -1,6 +1,11 @@
|
|
|
|
|
#!/usr/bin/env bash |
|
|
|
|
# Summary: Rehash jenv shims (run this after installing executables) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Provide jenv completions |
|
|
|
|
if [ "$1" = "--complete" ]; then |
|
|
|
|
echo --force |
|
|
|
|
exit |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
set -e |
|
|
|
|
[ -n "$JENV_DEBUG" ] && set -x |
|
|
|
|
@ -11,6 +16,14 @@ PROTOTYPE_SHIM_PATH="${SHIM_PATH}/.jenv-shim"
@@ -11,6 +16,14 @@ PROTOTYPE_SHIM_PATH="${SHIM_PATH}/.jenv-shim"
|
|
|
|
|
# Create the shims directory if it doesn't already exist. |
|
|
|
|
mkdir -p "$SHIM_PATH" |
|
|
|
|
|
|
|
|
|
remove_prototype_shim() { |
|
|
|
|
rm -f "$PROTOTYPE_SHIM_PATH" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if [ "$1" = "--force" ]; then |
|
|
|
|
remove_prototype_shim |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
# 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 |
|
|
|
|
@ -18,7 +31,7 @@ mkdir -p "$SHIM_PATH"
@@ -18,7 +31,7 @@ mkdir -p "$SHIM_PATH"
|
|
|
|
|
set -o noclobber |
|
|
|
|
{ echo > "$PROTOTYPE_SHIM_PATH" |
|
|
|
|
} 2>/dev/null || |
|
|
|
|
{ echo "jenv: cannot rehash: $PROTOTYPE_SHIM_PATH exists" |
|
|
|
|
{ echo "jenv: cannot rehash: $PROTOTYPE_SHIM_PATH exists, try 'jenv rehash --force' to override" |
|
|
|
|
exit 1 |
|
|
|
|
} >&2 |
|
|
|
|
set +o noclobber |
|
|
|
|
@ -27,10 +40,6 @@ set +o noclobber
@@ -27,10 +40,6 @@ set +o noclobber
|
|
|
|
|
# prototype shim when the process exits. |
|
|
|
|
trap remove_prototype_shim EXIT |
|
|
|
|
|
|
|
|
|
remove_prototype_shim() { |
|
|
|
|
rm -f "$PROTOTYPE_SHIM_PATH" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
remove_from_path() { |
|
|
|
|
local path_to_remove="$(expand_path "$1")" |
|
|
|
|
local result="" |
|
|
|
|
|