mirror of
https://github.com/pyenv/pyenv.git
synced 2024-12-01 07:23:24 -05:00
9368bebc35
This is only meant to be an example. There's a lot of simplification that works because my usage of Pyenv is simple.
31 lines
840 B
Bash
31 lines
840 B
Bash
PROTOTYPE_SOURCE_SHIM_PATH="${SHIM_PATH}/.pyenv-source-shim"
|
|
|
|
|
|
create_source_prototype_shim() {
|
|
if [ -f "${PROTOTYPE_SOURCE_SHIM_PATH}" ]; then
|
|
return
|
|
fi
|
|
|
|
cat > "${PROTOTYPE_SOURCE_SHIM_PATH}" <<SH
|
|
[ -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 $(cat "${BASH_SOURCE%/*}/source.d/"*".list" | sort -u | sed -e 's/#.*$//' | sed -e '/^[[:space:]]*$/d'); do
|
|
if [ -n "${shim##*/}" ]; then
|
|
source_shim="${SHIM_PATH}/${shim}"
|
|
if [ -e "${SOURCE_SHIM}" ]; then
|
|
create_source_prototype_shim
|
|
cp "${PROTOTYPE_SOURCE_SHIM_PATH}" "${source_shim}"
|
|
fi
|
|
fi
|
|
done
|
|
|
|
rm -f "${PROTOTYPE_SOURCE_SHIM_PATH}"
|