issue #29: Avoid GNU-specific find.

This commit is contained in:
Raphael Reitzig 2019-11-05 05:05:20 +01:00
parent 060169f5da
commit 7faecfd154
2 changed files with 64 additions and 64 deletions

View file

@ -47,5 +47,5 @@ script:
- ruby test/completion.rb - ruby test/completion.rb
- fish test/wrapper.fish - fish test/wrapper.fish
- fish test/reinitialize.fish - fish test/reinitialize.fish
- bash -c "source ${HOME}/.sdkman/bin/sdkman-init.sh && sdk install crash 1.3.0 && sdk uninstall crash 1.3.0" && fish test/10_zombies_new.fish - bash -c "source \"${HOME}/.sdkman/bin/sdkman-init.sh\" && sdk install crash 1.3.0 && sdk uninstall crash 1.3.0" && fish test/10_zombies_new.fish
- bash -c "rm -rf ~/.sdkman && sed -i 's/^.*\(sdkman\|SDKMAN\).*$//g' ~/.bashrc && echo 'SDKMAN uninstalled'" && fish -c "echo 'y' | sdk" && fish -c "sdk version" - bash -c "rm -rf \"${HOME}/.sdkman\" && sed -i 's/^.*\(sdkman\|SDKMAN\).*$//g' \"${HOME}/.bashrc\" && echo 'SDKMAN uninstalled'" && fish -c "echo 'y' | sdk" && fish -c "sdk version"

View file

@ -6,7 +6,7 @@
# Guard: SDKMAN! needs to be installed # Guard: SDKMAN! needs to be installed
if not test -f "$HOME/.sdkman/bin/sdkman-init.sh" if not test -f "$HOME/.sdkman/bin/sdkman-init.sh"
exit 0 exit 0
end end
# # # # # # # # # # # #
@ -15,44 +15,44 @@ end
# Test if there is no command # Test if there is no command
function __fish_sdkman_no_command function __fish_sdkman_no_command
set cmd (commandline -opc) set cmd (commandline -opc)
if [ (count $cmd) -eq 1 ] if [ (count $cmd) -eq 1 ]
return 0 return 0
end end
return 1 return 1
end end
# Test if the main command matches one of the parameters # Test if the main command matches one of the parameters
function __fish_sdkman_using_command function __fish_sdkman_using_command
set cmd (commandline -opc) set cmd (commandline -opc)
if [ (count $cmd) -eq 2 ] if [ (count $cmd) -eq 2 ]
if contains $cmd[2] $argv if contains $cmd[2] $argv
return 0 return 0
end
end end
end return 1
return 1
end end
function __fish_sdkman_specifying_candidate function __fish_sdkman_specifying_candidate
set cmd (commandline -opc) set cmd (commandline -opc)
if [ (count $cmd) -eq 3 ] # currently, sdk does not support multiple versions if [ (count $cmd) -eq 3 ] # currently, sdk does not support multiple versions
if contains $cmd[2] $argv ] if contains $cmd[2] $argv ]
return 0 return 0
end
end end
end return 1
return 1
end end
function __fish_sdkman_command_has_enough_parameters function __fish_sdkman_command_has_enough_parameters
set cmd (commandline -opc) set cmd (commandline -opc)
if [ (count $cmd) -ge (math $argv[1] + 2) ]; and contains $cmd[2] $argv[2..-1] if [ (count $cmd) -ge (math $argv[1] + 2) ]; and contains $cmd[2] $argv[2..-1]
return 0 return 0
end end
return 1 return 1
end end
# # # # # # # # # # # #
@ -60,22 +60,22 @@ end
# # # # # # # # # # # #
function __fish_sdkman_candidates function __fish_sdkman_candidates
cat "$HOME"/.sdkman/var/candidates | tr ',' '\n' cat "$HOME"/.sdkman/var/candidates | tr ',' '\n'
end end
function __fish_sdkman_candidates_with_versions function __fish_sdkman_candidates_with_versions
set regexpHome (string replace -a '/' '\\/' "$HOME/") set regexpHome (string replace -a '/' '\\/' "$HOME/")
find "$HOME"/.sdkman/candidates/ -name '*current*' -printf "%h\n" \
| sed -e "s/$regexpHome//" \ find "$HOME"/.sdkman/candidates/ -mindepth 2 -maxdepth 2 -name '*current' \
| cut -d '/' -f 3 \ | awk -F '/' '{ print $(NF-1) }' \
| sort -u | sort -u
end end
function __fish_sdkman_installed_versions function __fish_sdkman_installed_versions
set cmd (commandline -opc) set cmd (commandline -opc)
if [ -d "$HOME"/.sdkman/candidates/$cmd[3]/current ] if [ -d "$HOME"/.sdkman/candidates/$cmd[3]/current ]
ls -v1 "$HOME"/.sdkman/candidates/$cmd[3] | grep -v current ls -v1 "$HOME"/.sdkman/candidates/$cmd[3] | grep -v current
end end
end end
# # # # # # # # # # # #