mirror of
https://github.com/pyenv/pyenv.git
synced 2025-11-11 21:13:46 -05:00
Use readarray in bash v4+ to avoid rbenv init hanging
For just a handful of people, rbenv init would hang indefinitely. Turning on debugging output suggested that the `read` expression to split PATH into a bash array was hanging, but I could never reproduce this myself. Instead, this uses bash v4+ `readarray` if it's available, or falls back to bash v3 `read` with the default DELIM being a newline character. This will cause a regression if any PATH entries contain a literal newline character, but hopefully people are not relying on such paths.
This commit is contained in:
@@ -26,7 +26,12 @@ elif [ "$1" = "--no-sh" ]; then
|
||||
shift
|
||||
fi
|
||||
|
||||
IFS=: read -d '' -r -a paths <<<"$PATH" || true
|
||||
if [ "$(type -t readarray)" = "builtin" ]; then
|
||||
readarray -d : -t paths < <(printf "%s" "$PATH")
|
||||
else
|
||||
# bash 3.x compatibility
|
||||
IFS=: read -r -a paths <<<"$PATH" || true
|
||||
fi
|
||||
|
||||
shopt -s nullglob
|
||||
|
||||
|
||||
Reference in New Issue
Block a user