mirror of
https://github.com/ethauvin/sdkman-for-fish.git
synced 2025-04-25 05:17:11 -07:00
Refactoring: Define sdkman-init variable only once and "hide" it.
Also nicer test output.
This commit is contained in:
parent
597945453d
commit
8a14b1d570
3 changed files with 8 additions and 9 deletions
|
@ -7,10 +7,10 @@
|
|||
# MIT License (MIT)
|
||||
# https://github.com/reitzig/sdkman-for-fish
|
||||
|
||||
set sdkman_init "$HOME/.sdkman/bin/sdkman-init.sh"
|
||||
set __fish_sdkman_init "$HOME/.sdkman/bin/sdkman-init.sh"
|
||||
|
||||
# Guard: SDKMAN! needs to be installed
|
||||
if not test -f "$sdkman_init"
|
||||
if not test -f "$__fish_sdkman_init"
|
||||
exit 0
|
||||
end
|
||||
|
||||
|
@ -64,6 +64,6 @@ end
|
|||
# If this is a subshell of a(n initialized) fish, no initialization
|
||||
# necessary. Otherwise:
|
||||
if not set -q SDKMAN_DIR
|
||||
__fish_sdkman_run_in_bash "source $sdkman_init"
|
||||
__fish_sdkman_run_in_bash "source $__fish_sdkman_init"
|
||||
end
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
set sdkman_init "$HOME/.sdkman/bin/sdkman-init.sh"
|
||||
|
||||
# Guard: SDKMAN! needs to be installed
|
||||
if not test -f "$sdkman_init"
|
||||
if not test -f "$__fish_sdkman_init"
|
||||
exit 0
|
||||
end
|
||||
|
||||
# Declare the sdk command for fish
|
||||
function sdk -d "Manage SDKs"
|
||||
__fish_sdkman_run_in_bash "source $sdkman_init && sdk $argv"
|
||||
__fish_sdkman_run_in_bash "source $__fish_sdkman_init && sdk $argv"
|
||||
end
|
|
@ -25,8 +25,9 @@ for sdk_cmd in $test_commands
|
|||
bash -c "source \"$sdk_init\" && $sdk_cmd > sout_bash; echo \"\$?\" > status_bash; echo "\$PATH" > path_bash"
|
||||
fish -c "$sdk_cmd > sout_fish; echo \"\$status\" > status_fish; echo "\$PATH" > path_fish"
|
||||
|
||||
# Adjust for different path syntax: replace spaces with colons
|
||||
string join : (string split " " (cat path_fish)) > path_fish
|
||||
# For nicer diffs: one entry per line, sorted
|
||||
string split ":" (cat path_bash) | sort > path_bash
|
||||
string split " " (cat path_fish) | sort > path_fish
|
||||
|
||||
for out in sout status path
|
||||
if [ (checksum "$out"_bash) != (checksum "$out"_fish) ]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue