sdk: add support for local versions and optimize sed calls (#7870)

* 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à <marc.cornella@live.com>
This commit is contained in:
Andrea Nanni 2020-03-02 16:19:48 +01:00 committed by GitHub
parent 72707d92b1
commit 10ab2911d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 () {