From dfeda54079f31471f1eb194e692284514b16be54 Mon Sep 17 00:00:00 2001 From: Sakuragawa Misty Date: Sat, 21 Aug 2021 04:15:49 +0800 Subject: [PATCH] fixes checking of associative array in conda.bash --- pyenv.d/rehash/conda.bash | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/pyenv.d/rehash/conda.bash b/pyenv.d/rehash/conda.bash index 9e477862..aaf88884 100644 --- a/pyenv.d/rehash/conda.bash +++ b/pyenv.d/rehash/conda.bash @@ -34,14 +34,23 @@ make_shims() { } deregister_conda_shims() { - local shim - local shims=() - for shim in ${registered_shims}; do - if ! conda_shim "${shim}" 1>&2; then - shims[${#shims[*]}]="${shim}" - fi - done - registered_shims=" ${shims[@]} " + # adapted for Bash 4.x's associative array (#1749) + if declare -p registered_shims 2> /dev/null | grep -Eq '^(declare|typeset) \-A'; then + for shim in ${!registered_shims[*]}; do + if conda_shim "${shim}" 1>&2; then + unset registered_shims[${shim}] + fi + done + else + local shim + local shims=() + for shim in ${registered_shims}; do + if ! conda_shim "${shim}" 1>&2; then + shims[${#shims[*]}]="${shim}" + fi + done + registered_shims=" ${shims[@]} " + fi } if conda_exists; then