1
0
mirror of https://github.com/pyenv/pyenv.git synced 2025-11-16 07:13:53 -05:00

Bats: path_without: support multiple args

This commit is contained in:
Ivan Pozdeev
2021-09-16 00:34:00 +03:00
parent 6185bb55e6
commit 876be1bb04
3 changed files with 19 additions and 17 deletions

View File

@@ -111,24 +111,26 @@ assert() {
# Output a modified PATH that ensures that the given executable is not present,
# but in which system utils necessary for pyenv operation are still available.
path_without() {
local exe="$1"
local path=":${PATH}:"
local found alt util
for found in $(which -a "$exe"); do
found="${found%/*}"
if [ "$found" != "${PYENV_ROOT}/shims" ]; then
alt="${PYENV_TEST_DIR}/$(echo "${found#/}" | tr '/' '-')"
mkdir -p "$alt"
for util in bash head cut readlink greadlink; do
if [ -x "${found}/$util" ]; then
ln -s "${found}/$util" "${alt}/$util"
fi
done
path="${path/:${found}:/:${alt}:}"
fi
for exe; do
local found alt util
for found in $(PATH="$path" which -a "$exe"); do
found="${found%/*}"
if [ "$found" != "${PYENV_ROOT}/shims" ]; then
alt="${PYENV_TEST_DIR}/$(echo "${found#/}" | tr '/' '-')"
mkdir -p "$alt"
for util in bash head cut readlink greadlink which; do
if [ -x "${found}/$util" ]; then
ln -s "${found}/$util" "${alt}/$util"
fi
done
path="${path/:${found}:/:${alt}:}"
fi
done
done
path="${path#:}"
echo "${path%:}"
path="${path%:}"
echo "$path"
}
create_hook() {