From 10ab2911d35c84c120bae8f4e103b087fe19ce08 Mon Sep 17 00:00:00 2001 From: Andrea Nanni <37385837+ananni13@users.noreply.github.com> Date: Mon, 2 Mar 2020 16:19:48 +0100 Subject: [PATCH] sdk: add support for local versions and optimize sed calls (#7870) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added support for local sdk versions Added support for local versions (prefixed by '+'), so they are filtered out in _listInstallableVersions() and they are displayed correctly by _listAllVersion() * Optimize sed calls Co-authored-by: Marc Cornellà --- plugins/sdk/sdk.plugin.zsh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/sdk/sdk.plugin.zsh b/plugins/sdk/sdk.plugin.zsh index d00459b16..13876bfd0 100644 --- a/plugins/sdk/sdk.plugin.zsh +++ b/plugins/sdk/sdk.plugin.zsh @@ -51,12 +51,13 @@ _listInstalledVersions() { } _listInstallableVersions() { - __sdkman_list_versions $1 | grep "^ " | sed -e "s/\* /*/g" | \ - sed -e "s/>//g" | xargs -n 1 echo | grep -v "^*" + # Remove local (+) and installed (*) versions from the list + __sdkman_list_versions $1 | sed -e '/^[^ ]/d;s/[+*] [^ ]\+//g;s/>//g' } _listAllVersion() { - __sdkman_list_versions $1 | grep "^ " | sed -e "s/\*/ /g" | sed -e "s/>//g" + # Remove (*), (+), and (>) characters from the list + __sdkman_list_versions $1 | sed -e '/^[^ ]/d;s/[*+>] //g' } _sdk () {