Skip to content

Commit

Permalink
Merge pull request #1784 from marcospereira/support-sdkman-different-…
Browse files Browse the repository at this point in the history
…output-formats

Support multiple sdkman output formats
  • Loading branch information
Noah Gorny committed Jan 13, 2021
2 parents bac5041 + 08ff08e commit bc32b40
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions completion/available/sdkman.completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,18 @@ _sdkman_candidate_all_versions() {
if [ "$SDKMAN_OFFLINE_MODE" = "true" ]; then
CANDIDATE_VERSIONS=$CANDIDATE_LOCAL_VERSIONS
else
CANDIDATE_ONLINE_VERSIONS="$(__sdkman_list_versions "$1" | grep " " | grep "\." | cut -c 62-)"
CANDIDATE_VERSIONS="$(echo "$CANDIDATE_ONLINE_VERSIONS $CANDIDATE_LOCAL_VERSIONS" | tr ' ' '\n' | sort | uniq -u) "
# sdkman has a specific output format for Java candidate since
# there are multiple vendors and builds.
if [ "$candidate" = "java" ]; then
CANDIDATE_ONLINE_VERSIONS="$(__sdkman_list_versions "$candidate" | grep " " | grep "\." | cut -c 62-)"
else
CANDIDATE_ONLINE_VERSIONS="$(__sdkman_list_versions "$candidate" | grep " " | grep "\." | cut -c 6-)"
fi
# the last grep is used to filter out sdkman flags, such as:
# "+" - local version
# "*" - installed
# ">" - currently in use
CANDIDATE_VERSIONS="$(echo "$CANDIDATE_ONLINE_VERSIONS $CANDIDATE_LOCAL_VERSIONS" | tr ' ' '\n' | grep -v -e '^[[:space:]|\*|\>|\+]*$' | sort | uniq -u) "
fi

}
Expand Down

0 comments on commit bc32b40

Please sign in to comment.