diff --git a/libexec/rbenv-which b/libexec/rbenv-which index 768e8451..c4966c7a 100755 --- a/libexec/rbenv-which +++ b/libexec/rbenv-which @@ -27,7 +27,10 @@ remove_from_path() { return fi - for path in ${PATH//:/$'\n'}; do + local paths + IFS=: paths=($PATH) + + for path in "${paths[@]}"; do path="$(expand_path "$path" || true)" if [ -n "$path" ] && [ "$path" != "$path_to_remove" ]; then result="${result}${path}:"