mirror of
https://github.com/sdkman/sdkman-cli.git
synced 2026-05-19 05:58:43 -04:00
Fix substring bug on update.
This commit is contained in:
@@ -53,17 +53,21 @@ function __sdk_update {
|
||||
local cached_candidates_length=${#SDKMAN_CANDIDATES_CSV}
|
||||
__sdkman_echo_debug "Fresh and cached candidate lengths: $fresh_candidates_length $cached_candidates_length"
|
||||
|
||||
local candidates_diff=$(echo ${fresh_candidates[@]} ${cached_candidates[@]} | tr ' ' '\n' | sort | uniq -u | tr '\n' ',')
|
||||
local diff_candidates=$(echo ${fresh_candidates[@]} ${cached_candidates[@]} | tr ' ' '\n' | sort | uniq -u | tr '\n' ',')
|
||||
local diff_len=${#diff_candidates}
|
||||
local diff_endindex=$(expr $diff_len - 1)
|
||||
local diff_result=$(echo $diff_candidates | cut -c 1-$diff_endindex)
|
||||
|
||||
if (( fresh_candidates_length > cached_candidates_length )); then
|
||||
echo ""
|
||||
__sdkman_echo_green "Adding new candidates(s): ${candidates_diff:0:-1}"
|
||||
__sdkman_echo_green "Adding new candidates(s): $diff_result"
|
||||
echo "$fresh_candidates_csv" > "$SDKMAN_CANDIDATES_CACHE"
|
||||
echo ""
|
||||
__sdkman_echo_yellow "Please open a new terminal now..."
|
||||
|
||||
elif (( fresh_candidates_length < cached_candidates_length )); then
|
||||
echo ""
|
||||
__sdkman_echo_green "Removing obsolete candidates(s): ${candidates_diff:0:-1}"
|
||||
__sdkman_echo_green "Removing obsolete candidates(s): $diff_result"
|
||||
echo "$fresh_candidates_csv" > "$SDKMAN_CANDIDATES_CACHE"
|
||||
echo ""
|
||||
__sdkman_echo_yellow "Please open a new terminal now..."
|
||||
|
||||
Reference in New Issue
Block a user