mirror of
https://github.com/ethauvin/sdkman-for-fish.git
synced 2025-04-25 05:17:11 -07:00
Implements a nasty hack for issue #19: mangle sdkman-init.
This commit is contained in:
parent
ba46492522
commit
88c81dc479
3 changed files with 18 additions and 9 deletions
|
@ -7,13 +7,21 @@
|
|||
# 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"
|
||||
set __fish_sdkman_noexport_init "$HOME/.config/fisherman/sdkman-for-fish/sdkman-noexport-init.sh"
|
||||
|
||||
# Guard: SDKMAN! needs to be installed
|
||||
if not test -f "$sdkman_init"
|
||||
if not test -f "$__fish_sdkman_init"
|
||||
exit 0
|
||||
end
|
||||
|
||||
# Hack for issue #19: Create version of sdkman-init that doesn't export
|
||||
# any environment variables.
|
||||
if not test -f "$__fish_sdkman_noexport_init"
|
||||
sed -e 's/^\(\s*\).*\(export\|to_path\).*$/\1:/g' "$__fish_sdkman_init" \
|
||||
> $__fish_sdkman_noexport_init
|
||||
end
|
||||
|
||||
# Runs the given command in bash, capturing some side effects
|
||||
# and repeating them on the current fish shell.
|
||||
# Returns the same status code as the given command.
|
||||
|
@ -64,6 +72,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,11 @@
|
|||
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_noexport_init\" && sdk $argv"
|
||||
# __fish_sdkman_run_in_bash "source \"$__fish_sdkman_init\" && sdk $argv"
|
||||
# --> issue #19
|
||||
end
|
|
@ -26,8 +26,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