From 0d080212d255764a910db96da76a61c88008320f Mon Sep 17 00:00:00 2001 From: Raphael Reitzig <4246780+reitzig@users.noreply.github.com> Date: Tue, 30 Jul 2019 22:19:32 +0200 Subject: [PATCH 1/7] Verify (re-)initialization of SDKMAN env vars works. - Add new test that covers the two cases considered so far. Housekeeping: - Add `.gitignore` - Add `.editorconfig` --- .editorconfig | 5 +++++ .gitignore | 2 ++ .travis.yml | 1 + test/reinitialize.fish | 25 +++++++++++++++++++++++++ 4 files changed, 33 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100755 test/reinitialize.fish diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..0009889 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,5 @@ +[*] +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..98c52b8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +test/*_fish +test/*_bash diff --git a/.travis.yml b/.travis.yml index 33a29f7..c227e31 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,5 +23,6 @@ install: script: - ruby test/completion.rb - fish test/wrapper.fish + - fish test/reinitialize.fish - bash -c "sdk install crash 1.3.0; sdk uninstall crash 1.3.0"; fish test/10_zombies_new.fish diff --git a/test/reinitialize.fish b/test/reinitialize.fish new file mode 100755 index 0000000..23cb921 --- /dev/null +++ b/test/reinitialize.fish @@ -0,0 +1,25 @@ +# If either of +# - $SDKMAN_DIR is unset +# - $SDKMAN_DIR points to a directory not owned by the current user +# is true, sdkman-for-fish should run sdkman's init script. + +# Assumes sdkman-for-fish is installed +set proper_value "$SDKMAN_DIR" + +begin + set -e SDKMAN_DIR + set in_new_shell (fish -lc 'echo $SDKMAN_DIR') + if [ "$in_new_shell" != "$proper_value" ] + echo "SDKMAN_DIR initialized to $in_new_shell instead of $proper_value" + exit 1 + end +end + +begin + set SDKMAN_DIR "/" # belongs to root, who hopefully doesn't run this + set in_new_shell (fish -lc 'echo $SDKMAN_DIR') + if [ "$in_new_shell" != "$proper_value" ] + echo "SDKMAN_DIR reinitialized to $in_new_shell instead of $proper_value" + exit 1 + end +end From 3055e88e1f8b3179f8afe78dec860b5890f1de11 Mon Sep 17 00:00:00 2001 From: Raphael Reitzig <4246780+reitzig@users.noreply.github.com> Date: Tue, 30 Jul 2019 22:33:56 +0200 Subject: [PATCH 2/7] Reformat .travis.yml --- .travis.yml | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index c227e31..845a898 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,28 +1,27 @@ env: - - FISH=release-2 - - FISH=release-3 + - FISH=release-2 + - FISH=release-3 matrix: - allow_failures: - - env: FISH=release-3 + allow_failures: + - env: FISH=release-3 sudo: required before_install: - - sudo add-apt-repository -y ppa:fish-shell/${FISH} - - sudo apt-get update - - sudo apt-get -y install fish - - curl -s "https://get.sdkman.io" | bash - - bash test/prepare_tests.sh + - sudo add-apt-repository -y ppa:fish-shell/${FISH} + - sudo apt-get update + - sudo apt-get -y install fish + - curl -s "https://get.sdkman.io" | bash + - bash test/prepare_tests.sh install: - - mkdir -p "${HOME}"/.config/fish/{completions,conf.d,functions} - - cp completions/* "${HOME}"/.config/fish/completions/ - - cp conf.d/* "${HOME}"/.config/fish/conf.d/ - - cp functions/* "${HOME}"/.config/fish/functions/ + - mkdir -p "${HOME}"/.config/fish/{completions,conf.d,functions} + - cp completions/* "${HOME}"/.config/fish/completions/ + - cp conf.d/* "${HOME}"/.config/fish/conf.d/ + - cp functions/* "${HOME}"/.config/fish/functions/ script: - - ruby test/completion.rb - - fish test/wrapper.fish - - fish test/reinitialize.fish - - bash -c "sdk install crash 1.3.0; sdk uninstall crash 1.3.0"; fish test/10_zombies_new.fish - + - ruby test/completion.rb + - fish test/wrapper.fish + - fish test/reinitialize.fish + - bash -c "sdk install crash 1.3.0; sdk uninstall crash 1.3.0"; fish test/10_zombies_new.fish From c02c756baf0aec33a9b7ad009fd9bb0463be5001 Mon Sep 17 00:00:00 2001 From: Raphael Reitzig <4246780+reitzig@users.noreply.github.com> Date: Wed, 31 Jul 2019 02:18:08 +0200 Subject: [PATCH 3/7] issue #27 Fish 3 compatibility: replace `math` with `test` in conditions cf. https://github.com/fish-shell/fish-shell/issues/4777 --- test/wrapper.fish | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/wrapper.fish b/test/wrapper.fish index bd95ac0..67568c2 100644 --- a/test/wrapper.fish +++ b/test/wrapper.fish @@ -23,12 +23,12 @@ echo "Testing the sdk wrapper" set failures 0 for sdk_cmd in $test_commands echo " Testing '$sdk_cmd'" - bash -c "source \"$sdk_init\" && $sdk_cmd > sout_bash; - echo \"\$?\" > status_bash; + bash -c "source \"$sdk_init\" && $sdk_cmd > sout_bash; + echo \"\$?\" > status_bash; echo \"\$PATH\" > path_bash; echo \"\$ANT_HOME\" > anthome_bash" - fish -c "$sdk_cmd > sout_fish; - echo \"\$status\" > status_fish; + fish -c "$sdk_cmd > sout_fish; + echo \"\$status\" > status_fish; echo \"\$PATH\" > path_fish; echo \"\$ANT_HOME\" > anthome_fish" @@ -52,4 +52,4 @@ rm {sout,status,path}_{bash,fish} echo "Ran $test_count commands with 3 checks each." echo "$failures/$check_count checks failed." -exit (math $failures != 0) \ No newline at end of file +exit (test $failures != 0) From 6934dbfb0f369f2d062c2da14c58c4df0d563f7d Mon Sep 17 00:00:00 2001 From: Raphael Reitzig <4246780+reitzig@users.noreply.github.com> Date: Wed, 31 Jul 2019 02:23:12 +0200 Subject: [PATCH 4/7] issue #27 Fish 3 compatibility: adapt to new PATH handling cf. https://github.com/fish-shell/fish-shell/issues/436 --- test/wrapper.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/wrapper.fish b/test/wrapper.fish index 67568c2..524c845 100644 --- a/test/wrapper.fish +++ b/test/wrapper.fish @@ -34,7 +34,7 @@ for sdk_cmd in $test_commands # For nicer diffs: one entry per line, sorted string split ":" (cat path_bash) | sort > path_bash - string split " " (cat path_fish) | sort > path_fish + string split ":" (cat path_fish) | sort > path_fish for out in sout status path anthome if [ (checksum "$out"_bash) != (checksum "$out"_fish) ] From 018c9f01a30225220e79201e6cce428cf2bcdec0 Mon Sep 17 00:00:00 2001 From: Raphael Reitzig <4246780+reitzig@users.noreply.github.com> Date: Wed, 31 Jul 2019 02:32:07 +0200 Subject: [PATCH 5/7] issue #27 Fish 3 compatibility: Remove math/test condition completely. --- test/wrapper.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/wrapper.fish b/test/wrapper.fish index 524c845..fd648f5 100644 --- a/test/wrapper.fish +++ b/test/wrapper.fish @@ -52,4 +52,4 @@ rm {sout,status,path}_{bash,fish} echo "Ran $test_count commands with 3 checks each." echo "$failures/$check_count checks failed." -exit (test $failures != 0) +exit $failures From 735760bb252d324c96a21d2cc018a5329b800fcc Mon Sep 17 00:00:00 2001 From: Raphael Reitzig <4246780+reitzig@users.noreply.github.com> Date: Wed, 31 Jul 2019 02:47:36 +0200 Subject: [PATCH 6/7] issue #27 Fish 2 compatibility: support old PATH handling, as well --- test/wrapper.fish | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/wrapper.fish b/test/wrapper.fish index fd648f5..d5a496b 100644 --- a/test/wrapper.fish +++ b/test/wrapper.fish @@ -34,7 +34,10 @@ for sdk_cmd in $test_commands # For nicer diffs: one entry per line, sorted string split ":" (cat path_bash) | sort > path_bash - string split ":" (cat path_fish) | sort > path_fish + string split ":" (cat path_fish) \ + | string split " " \ + | sort > path_fish + # split by spaces for fish 2.* for out in sout status path anthome if [ (checksum "$out"_bash) != (checksum "$out"_fish) ] From 04a8c8574a14260a8277a7e9fbf396e8069ac03e Mon Sep 17 00:00:00 2001 From: Raphael Reitzig <4246780+reitzig@users.noreply.github.com> Date: Wed, 31 Jul 2019 02:56:40 +0200 Subject: [PATCH 7/7] issue #27 Fish 3 compatibility: make fish 3 tests mandatory. --- .travis.yml | 5 +---- README.md | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 845a898..c4fa685 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,10 +2,6 @@ env: - FISH=release-2 - FISH=release-3 -matrix: - allow_failures: - - env: FISH=release-3 - sudo: required before_install: - sudo add-apt-repository -y ppa:fish-shell/${FISH} @@ -19,6 +15,7 @@ install: - cp completions/* "${HOME}"/.config/fish/completions/ - cp conf.d/* "${HOME}"/.config/fish/conf.d/ - cp functions/* "${HOME}"/.config/fish/functions/ + - uname -a; fish --version script: - ruby test/completion.rb diff --git a/README.md b/README.md index 34604c7..c59d15b 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Makes command `sdk` from [SDKMAN!] available in fish. Also provides auto-completion and adds binaries from installed SDKs to the PATH. -Tested with fish 2.7.1 and SDKMAN! 5.7.3. +Tested with fish 2.7.1 and 3.0.2, and SDKMAN! 5.7.3. ## Install @@ -24,7 +24,7 @@ with `sdk` as you would expect. ## Acknowledgements - * Completion originally by [Ted Wise](https://github.com/ctwise); see his + * Completion originally by [Ted Wise](https://github.com/ctwise); see his [blog post from 2016](http://tedwise.com/2016/02/26/using-sdkman-with-the-fish-shell). * Binary loading originally by [Koala Yeung](https://github.com/yookoala); see [his comment on sdkman/sdkman-cli#294](https://github.com/sdkman/sdkman-cli/issues/294#issuecomment-318252058).