Workaround for scripts in $PATH which needs to be source'd (#100, #688)

This commit is contained in:
Yamashita, Yuu 2017-07-20 01:25:12 +00:00
parent 0314de0c73
commit 52d6acc3b0
2 changed files with 31 additions and 0 deletions

View file

@ -0,0 +1,30 @@
PROTOTYPE_SOURCE_SHIM_PATH="${SHIM_PATH}/.pyenv-source-shim"
shims=()
for shim in $(cat "${BASH_SOURCE%/*}/source.txt"); do
if [ -n "${shim%%#*}" ]; then
shims[${#shims[*]}]="${shim})return 0;;"
fi
done
eval "source_shim(){ case \"\$1\" in ${shims[@]} *)return 1;;esac;}"
cat > "${PROTOTYPE_SOURCE_SHIM_PATH}" <<SH
#!/usr/bin/env bash
[ -n "\$PYENV_DEBUG" ] && set -x
export PYENV_ROOT="${PYENV_ROOT}"
program="\$("$(command -v pyenv)" which "\${BASH_SOURCE##*/}")"
if [ -e "\${program}" ]; then
. "\${program}" "\$@"
fi
SH
chmod +x "${PROTOTYPE_SOURCE_SHIM_PATH}"
shopt -s nullglob
for shim in "${SHIM_PATH}/"*; do
if source_shim "${shim}"; then
cp "${PROTOTYPE_SOURCE_SHIM_PATH}" "${shim}"
fi
done
shopt -u nullglob
rm -f "${PROTOTYPE_SOURCE_SHIM_PATH}"

View file

@ -0,0 +1 @@
gettext.sh