From 8275e15cb0d80e1e2314e238940c63edd5dd1579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Sun, 9 Oct 2022 14:48:13 +0200 Subject: [PATCH] Use `read -a` to split output into an array (#1450) --- libexec/rbenv-commands | 2 +- libexec/rbenv-exec | 5 ++--- libexec/rbenv-hooks | 2 +- libexec/rbenv-init | 3 ++- libexec/rbenv-rehash | 6 ++---- libexec/rbenv-version-name | 5 ++--- libexec/rbenv-version-origin | 5 ++--- libexec/rbenv-which | 5 ++--- 8 files changed, 14 insertions(+), 19 deletions(-) diff --git a/libexec/rbenv-commands b/libexec/rbenv-commands index 4c3d845..e084331 100755 --- a/libexec/rbenv-commands +++ b/libexec/rbenv-commands @@ -20,7 +20,7 @@ elif [ "$1" = "--no-sh" ]; then shift fi -IFS=: paths=($PATH) +IFS=: read -d '' -r -a paths <<<"$PATH" || true shopt -s nullglob diff --git a/libexec/rbenv-exec b/libexec/rbenv-exec index e05ce51..3520c9d 100755 --- a/libexec/rbenv-exec +++ b/libexec/rbenv-exec @@ -33,10 +33,9 @@ export RBENV_VERSION RBENV_COMMAND_PATH="$(rbenv-which "$RBENV_COMMAND")" RBENV_BIN_PATH="${RBENV_COMMAND_PATH%/*}" -OLDIFS="$IFS" -IFS=$'\n' scripts=(`rbenv-hooks exec`) -IFS="$OLDIFS" +IFS=$'\n' read -d '' -r -a scripts <<<"$(rbenv-hooks exec)" || true for script in "${scripts[@]}"; do + # shellcheck disable=SC1090 source "$script" done diff --git a/libexec/rbenv-hooks b/libexec/rbenv-hooks index c3d9f63..8d1f487 100755 --- a/libexec/rbenv-hooks +++ b/libexec/rbenv-hooks @@ -21,7 +21,7 @@ if [ -z "$RBENV_COMMAND" ]; then exit 1 fi -IFS=: hook_paths=($RBENV_HOOK_PATH) +IFS=: read -r -a hook_paths <<<"$RBENV_HOOK_PATH" shopt -s nullglob for path in "${hook_paths[@]}"; do diff --git a/libexec/rbenv-init b/libexec/rbenv-init index 00e2274..3d23f66 100755 --- a/libexec/rbenv-init +++ b/libexec/rbenv-init @@ -126,7 +126,8 @@ if [ -z "$no_rehash" ]; then echo 'command rbenv rehash 2>/dev/null' fi -commands=(`rbenv-commands --sh`) +IFS=$'\n' read -d '' -r -a commands <<<"$(rbenv-commands --sh)" || true + case "$shell" in fish ) cat <