Fix issue if md5sum is used instead of md5 (#6958)

* Fix issue if md5sum is used instead of md5

Both have a different output which results in different array sized

Signed-off-by: Ron Gebauer <ron.gebauer@raytion.com>

* Add feedback

Signed-off-by: Ron Gebauer <ron.gebauer@raytion.com>
This commit is contained in:
Ron Gebauer 2020-05-07 21:02:22 +02:00 committed by GitHub
parent 02e9486559
commit 54f3fbbf8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,12 +7,13 @@ end
function __fish_gradle_create_completion_cache_file
# Set up cache directory
if test -z $XDG_CACHE_HOME
if test -z "$XDG_CACHE_HOME"
set XDG_CACHE_HOME $HOME/.cache
end
mkdir -m 700 -p $XDG_CACHE_HOME/gradle-completions
mkdir -m 700 -p "$XDG_CACHE_HOME/gradle-completions"
string trim -- $XDG_CACHE_HOME/gradle-completions/(__fish_md5 -s $argv[1] | string split ' = ')[2]
set -l md5Hash (__fish_md5 -s $argv[1] | string replace -r '.* = ' '')
string trim -- "$XDG_CACHE_HOME/gradle-completions/$md5Hash"
end
##############################
@ -51,12 +52,12 @@ function __fish_gradle_get_task_completion
end
set -l gradle_cache_file (__fish_gradle_create_completion_cache_file "{$PWD}-tasks")
if not command test -f $gradle_cache_file -a -s $gradle_cache_file
command gradle -q tasks --all 2>/dev/null | string match --regex '^[a-z][A-z:]+.*' | string replace ' - ' \t >$gradle_cache_file
if not test -f "$gradle_cache_file" -a -s "$gradle_cache_file"
command gradle -q tasks --all 2>/dev/null | string match --regex '^[a-z][A-z:]+.*' | string replace ' - ' \t >"$gradle_cache_file"
end
# return possible tasks
string trim -- <$gradle_cache_file
string trim -- <"$gradle_cache_file"
end
complete --command 'gw' --command 'gradle' --command 'gradlew' \