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..c4fa685 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,27 +1,24 @@ env: - - FISH=release-2 - - FISH=release-3 - -matrix: - allow_failures: - - env: FISH=release-3 + - FISH=release-2 + - 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/ + - uname -a; fish --version script: - - ruby test/completion.rb - - fish test/wrapper.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 diff --git a/README.md b/README.md index 8d9782e..26ce536 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. :warning: Tests indicate that fish 3.x is incompatible. @@ -26,7 +26,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). 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 diff --git a/test/wrapper.fish b/test/wrapper.fish index bd95ac0..d5a496b 100644 --- a/test/wrapper.fish +++ b/test/wrapper.fish @@ -23,18 +23,21 @@ 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" # 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) ] @@ -52,4 +55,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 $failures