From 53b574de2c3f755d28bbc7febdcd8d490db73303 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Wed, 4 Jul 2018 00:36:44 +0100 Subject: [PATCH] Further tweaks to update command output. --- src/main/bash/sdkman-update.sh | 10 +++------- .../sdkman/specs/CandidatesCacheUpdateSpec.groovy | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main/bash/sdkman-update.sh b/src/main/bash/sdkman-update.sh index 94d38c10..91c1a876 100644 --- a/src/main/bash/sdkman-update.sh +++ b/src/main/bash/sdkman-update.sh @@ -53,21 +53,17 @@ 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 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) - + local diff_candidates=$(echo ${fresh_candidates[@]} ${cached_candidates[@]} | tr ' ' '\n' | sort | uniq -u | tr '\n' ' ') if (( fresh_candidates_length > cached_candidates_length )); then echo "" - __sdkman_echo_green "Adding new candidates(s): $diff_result" + __sdkman_echo_green "Adding new candidates(s): $diff_candidates" 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): $diff_result" + __sdkman_echo_green "Removing obsolete candidates(s): $diff_candidates" echo "$fresh_candidates_csv" > "$SDKMAN_CANDIDATES_CACHE" echo "" __sdkman_echo_yellow "Please open a new terminal now..." diff --git a/src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy b/src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy index ad5c726f..9d288b7b 100644 --- a/src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy +++ b/src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy @@ -106,7 +106,7 @@ class CandidatesCacheUpdateSpec extends SdkmanEnvSpecification { bash.execute("sdk update") then: - bash.output.contains('Adding new candidates(s): groovy,scala') + bash.output.contains('Adding new candidates(s): groovy scala') and: candidatesCache.text.trim() == "groovy,scala"