Skip to content

Commit 18971a7

Browse files
authored
Simplify bash csv parsing in sdkman-init.sh (#754)
1 parent 470554a commit 18971a7

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/main/bash/sdkman-init.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ for f in "${scripts[@]}"; do
8282
source "$f"
8383
done
8484
IFS="$OLD_IFS"
85-
unset scripts f
85+
unset OLD_IFS scripts f
8686

8787
# Load the sdkman config if it exists.
8888
if [ -f "${SDKMAN_DIR}/etc/config" ]; then
@@ -114,10 +114,7 @@ __sdkman_echo_debug "Setting candidates csv: $SDKMAN_CANDIDATES_CSV"
114114
if [[ "$zsh_shell" == 'true' ]]; then
115115
SDKMAN_CANDIDATES=(${(s:,:)SDKMAN_CANDIDATES_CSV})
116116
else
117-
OLD_IFS="$IFS"
118-
IFS=","
119-
SDKMAN_CANDIDATES=(${SDKMAN_CANDIDATES_CSV})
120-
IFS="$OLD_IFS"
117+
IFS=',' read -a SDKMAN_CANDIDATES <<< "${SDKMAN_CANDIDATES_CSV}"
121118
fi
122119

123120
export SDKMAN_CANDIDATES_DIR="${SDKMAN_DIR}/candidates"
@@ -129,5 +126,5 @@ for candidate_name in "${SDKMAN_CANDIDATES[@]}"; do
129126
__sdkman_prepend_candidate_to_path "$candidate_dir"
130127
fi
131128
done
132-
unset OLD_IFS candidate_name candidate_dir
129+
unset candidate_name candidate_dir
133130
export PATH

0 commit comments

Comments
 (0)