Merge branch 'dev'

This commit is contained in:
Raphael Reitzig 2019-11-06 22:12:54 +01:00
commit c9fd8d58f2
9 changed files with 181 additions and 78 deletions

View file

@ -8,5 +8,8 @@ indent_size = 4
trim_trailing_whitespace = true trim_trailing_whitespace = true
insert_final_newline = true insert_final_newline = true
[*.{yaml,yml}]
indent_size = 2
[*.md] [*.md]
trim_trailing_whitespace = false trim_trailing_whitespace = false

View file

@ -1,12 +1,37 @@
env: matrix:
- FISH=release-2 include:
- FISH=release-3 - dist: bionic
env: FISH=2
addons:
apt:
sources:
- sourceline: "ppa:fish-shell/release-2"
packages:
- fish
- dist: bionic
env: FISH=3
addons:
apt:
sources:
- sourceline: "ppa:fish-shell/release-3"
packages:
- fish
- os: osx
env: FISH=2
addons:
homebrew:
packages:
- 'test/Homebrew-Formula-fish-2.7.1.rb'
update: true # TODO: build should be green without, but isn't
- os: osx
env: FISH=3
addons:
homebrew:
packages:
- fish # --> latest, i.e. >=3.0.2
update: true # TODO: build should be green without, but isn't
sudo: required
before_install: 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 - curl -s "https://get.sdkman.io" | bash
- bash test/prepare_tests.sh - bash test/prepare_tests.sh
@ -21,5 +46,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 - fish -c "sdk install crash 1.3.0; and sdk uninstall crash 1.3.0" > /dev/null && fish test/check_for_path_zombies.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 test/remove_sdkman.sh > /dev/null && fish -c "echo 'y' | sdk" > /dev/null && fish -c "sdk version"

View file

@ -5,7 +5,11 @@
Makes command `sdk` from [SDKMAN!] usable from fish, including auto-completion. Makes command `sdk` from [SDKMAN!] usable from fish, including auto-completion.
Also adds binaries from installed SDKs to the PATH. Also adds binaries from installed SDKs to the PATH.
Tested with fish 2.7.1 and 3.0.2, and SDKMAN! 5.7.4. Version 1.4.0 tested with
- fish 2.7.1 and 3.0.2, and
- SDKMAN! 5.7.4, on
- Ubuntu 18.04 LTS and macOS 10.13.
## Install ## Install

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
# # # # # # # # # # # #
@ -14,45 +14,45 @@ 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
# # # # # # # # # # # #
@ -87,26 +87,26 @@ complete -c sdk -f -n '__fish_sdkman_no_command' \
-a 'i install' \ -a 'i install' \
-d 'Install new version' -d 'Install new version'
complete -c sdk -f -n '__fish_sdkman_using_command i install' \ complete -c sdk -f -n '__fish_sdkman_using_command i install' \
-a "(__fish_sdkman_candidates)" -a "(__fish_sdkman_candidates)"
complete -c sdk -f -n '__fish_sdkman_specifying_candidate i install' \ complete -c sdk -f -n '__fish_sdkman_specifying_candidate i install' \
# TODO complete available versions --> #4 # TODO complete available versions --> #4
-a 'a.b.c' \ -a 'a.b.c' \
-d "version list unavailable" -d "version list unavailable"
complete -c sdk -f -n '__fish_sdkman_specifying_candidate i install' \ complete -c sdk -f -n '__fish_sdkman_specifying_candidate i install' \
-a 'x.y.z' \ -a 'x.y.z' \
-d "Add your own; specify path!" -d "Add your own; specify path!"
# Implicit: complete files as fourth parameter # Implicit: complete files as fourth parameter
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 3 i install' complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 3 i install'
# block # block
# uninstall # uninstall
complete -c sdk -f -n '__fish_sdkman_no_command' \ complete -c sdk -f -n '__fish_sdkman_no_command' \
-a 'rm uninstall' -d 'Uninstall version' -a 'rm uninstall' -d 'Uninstall version'
complete -c sdk -f -n '__fish_sdkman_using_command rm uninstall' \ complete -c sdk -f -n '__fish_sdkman_using_command rm uninstall' \
-a "(__fish_sdkman_candidates_with_versions)" -a "(__fish_sdkman_candidates_with_versions)"
complete -c sdk -f -n '__fish_sdkman_specifying_candidate rm uninstall' \ complete -c sdk -f -n '__fish_sdkman_specifying_candidate rm uninstall' \
-a "(__fish_sdkman_installed_versions)" -a "(__fish_sdkman_installed_versions)"
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 2 rm uninstall' complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 2 rm uninstall'
# block # block
# list # list
@ -114,19 +114,19 @@ complete -c sdk -f -n '__fish_sdkman_no_command' \
-a 'ls list' \ -a 'ls list' \
-d 'List versions' -d 'List versions'
complete -c sdk -f -n '__fish_sdkman_using_command ls list' \ complete -c sdk -f -n '__fish_sdkman_using_command ls list' \
-a "(__fish_sdkman_candidates)" -a "(__fish_sdkman_candidates)"
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 1 ls list' complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 1 ls list'
# block # block
# use # use
complete -c sdk -f -n '__fish_sdkman_no_command' \ complete -c sdk -f -n '__fish_sdkman_no_command' \
-a 'u use' \ -a 'u use' \
-d 'Use specific version' -d 'Use specific version'
complete -c sdk -f -n '__fish_sdkman_using_command u use' \ complete -c sdk -f -n '__fish_sdkman_using_command u use' \
-a "(__fish_sdkman_candidates_with_versions)" -a "(__fish_sdkman_candidates_with_versions)"
complete -c sdk -f -n '__fish_sdkman_specifying_candidate u use' \ complete -c sdk -f -n '__fish_sdkman_specifying_candidate u use' \
-a "(__fish_sdkman_installed_versions)" -a "(__fish_sdkman_installed_versions)"
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 2 u use' complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 2 u use'
# block # block
# default # default
@ -134,10 +134,10 @@ complete -c sdk -f -n '__fish_sdkman_no_command' \
-a 'd default' \ -a 'd default' \
-d 'Set default version' -d 'Set default version'
complete -c sdk -f -n '__fish_sdkman_using_command d default' \ complete -c sdk -f -n '__fish_sdkman_using_command d default' \
-a "(__fish_sdkman_candidates_with_versions)" -a "(__fish_sdkman_candidates_with_versions)"
complete -c sdk -f -n '__fish_sdkman_specifying_candidate d default' \ complete -c sdk -f -n '__fish_sdkman_specifying_candidate d default' \
-a "(__fish_sdkman_installed_versions)" -a "(__fish_sdkman_installed_versions)"
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 2 d default' complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 2 d default'
# block # block
# current # current
@ -145,8 +145,8 @@ complete -c sdk -f -n '__fish_sdkman_no_command' \
-a 'c current' \ -a 'c current' \
-d 'Display current version' -d 'Display current version'
complete -c sdk -f -n '__fish_sdkman_using_command c current' \ complete -c sdk -f -n '__fish_sdkman_using_command c current' \
-a "(__fish_sdkman_candidates)" -a "(__fish_sdkman_candidates)"
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 1 c current' complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 1 c current'
# block # block
# upgrade # upgrade
@ -154,29 +154,29 @@ complete -c sdk -f -n '__fish_sdkman_no_command' \
-a 'ug upgrade' \ -a 'ug upgrade' \
-d 'Display what is outdated' -d 'Display what is outdated'
complete -c sdk -f -n '__fish_sdkman_using_command ug upgrade' \ complete -c sdk -f -n '__fish_sdkman_using_command ug upgrade' \
-a "(__fish_sdkman_candidates_with_versions)" -a "(__fish_sdkman_candidates_with_versions)"
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 1 ug upgrade' complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 1 ug upgrade'
# block # block
# version # version
complete -c sdk -f -n '__fish_sdkman_no_command' \ complete -c sdk -f -n '__fish_sdkman_no_command' \
-a 'v version' \ -a 'v version' \
-d 'Display version' -d 'Display version'
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 0 v version' complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 0 v version'
# block # block
# broadcast # broadcast
complete -c sdk -f -n '__fish_sdkman_no_command' \ complete -c sdk -f -n '__fish_sdkman_no_command' \
-a 'b broadcast' \ -a 'b broadcast' \
-d 'Display broadcast message' -d 'Display broadcast message'
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 0 b broadcast' complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 0 b broadcast'
# block # block
# help # help
complete -c sdk -f -n '__fish_sdkman_no_command' \ complete -c sdk -f -n '__fish_sdkman_no_command' \
-a 'h help' \ -a 'h help' \
-d 'Display help message' -d 'Display help message'
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 0 h help' complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 0 h help'
# block # block
# offline # offline
@ -189,7 +189,7 @@ complete -c sdk -f -n '__fish_sdkman_using_command offline' \
complete -c sdk -f -n '__fish_sdkman_using_command offline' \ complete -c sdk -f -n '__fish_sdkman_using_command offline' \
-a 'disable' \ -a 'disable' \
-d 'Turn on all features' -d 'Turn on all features'
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 1 offline' complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 1 offline'
# block # block
# selfupdate # selfupdate
@ -199,14 +199,14 @@ complete -c sdk -f -n '__fish_sdkman_no_command' \
complete -c sdk -f -n '__fish_sdkman_using_command selfupdate' \ complete -c sdk -f -n '__fish_sdkman_using_command selfupdate' \
-a 'force' \ -a 'force' \
-d 'Force re-install of current version' -d 'Force re-install of current version'
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 1 selfupdate' complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 1 selfupdate'
# block # block
# update # update
complete -c sdk -f -n '__fish_sdkman_no_command' \ complete -c sdk -f -n '__fish_sdkman_no_command' \
-a 'update' \ -a 'update' \
-d 'Reload the candidate list' -d 'Reload the candidate list'
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 0 update' complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 0 update'
# block # block
# flush # flush
@ -222,5 +222,5 @@ complete -c sdk -f -n '__fish_sdkman_using_command flush' \
complete -c sdk -f -n '__fish_sdkman_using_command flush' \ complete -c sdk -f -n '__fish_sdkman_using_command flush' \
-a 'temp' \ -a 'temp' \
-d 'Clear installation prep folder' -d 'Clear installation prep folder'
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 1 flush' complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 1 flush'
# block # block

View file

@ -22,8 +22,8 @@ if begin not test -f "$__fish_sdkman_noexport_init";
or env test "$__fish_sdkman_init" -nt "$__fish_sdkman_noexport_init" or env test "$__fish_sdkman_init" -nt "$__fish_sdkman_noexport_init"
end end
mkdir -p (dirname $__fish_sdkman_noexport_init) mkdir -p (dirname $__fish_sdkman_noexport_init)
sed -e 's/^\(\s*\).*\(export\|to_path\).*$/\1:/g' "$__fish_sdkman_init" \ sed -E -e 's/^(\s*).*(export|to_path).*$/\1:/g' "$__fish_sdkman_init" \
> $__fish_sdkman_noexport_init > "$__fish_sdkman_noexport_init"
end end
# Runs the given command in bash, capturing some side effects # Runs the given command in bash, capturing some side effects
@ -66,7 +66,7 @@ function __fish_sdkman_run_in_bash
if test -n value if test -n value
set -gx $var $value set -gx $var $value
# Note: This makes SDKMAN_OFFLINE_MODE an environment variable. # Note: This makes SDKMAN_OFFLINE_MODE an environment variable.
# That gives it the behavariour we _want_! # That gives it the behaviour we _want_!
end end
end end
end end
@ -77,7 +77,7 @@ end
# If this is a subshell of a(n initialized) fish owned by the same user, # If this is a subshell of a(n initialized) fish owned by the same user,
# no initialization necessary. # no initialization necessary.
# Otherwise: # Otherwise:
if not set -q SDKMAN_DIR; or test (stat -c "%U" $SDKMAN_DIR) != (whoami) if not set -q SDKMAN_DIR; or test (ls -ld "$SDKMAN_DIR" | awk '{print $3}') != (whoami)
set -e SDKMAN_DIR set -e SDKMAN_DIR
__fish_sdkman_run_in_bash "source $__fish_sdkman_init" __fish_sdkman_run_in_bash "source $__fish_sdkman_init"
end end

View file

@ -0,0 +1,60 @@
class HomebrewFormulaFish271 < Formula
desc "User-friendly command-line shell for UNIX-like operating systems"
homepage "https://fishshell.com"
url "https://github.com/fish-shell/fish-shell/releases/download/2.7.1/fish-2.7.1.tar.gz"
mirror "https://fishshell.com/files/2.7.1/fish-2.7.1.tar.gz"
sha256 "e42bb19c7586356905a58578190be792df960fa81de35effb1ca5a5a981f0c5a"
bottle do
sha256 "affac16a396410a500241266dbbbd8752562c9b800d9e4f2ef8de279c6fdb6aa" => :high_sierra
sha256 "335538a7ea7f9613474f7321af0a1d519b61b0fc4be97a1744a7ea7bef7ff7e3" => :sierra
sha256 "463cfa8edc0603761f25e0ba4e49524f69a1d856263d370d1de5fb8698dd5ccf" => :el_capitan
end
head do
url "https://github.com/fish-shell/fish-shell.git", :shallow => false
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "doxygen" => :build
end
depends_on "pcre2"
def install
system "autoreconf", "--no-recursive" if build.head?
# In Homebrew's 'superenv' sed's path will be incompatible, so
# the correct path is passed into configure here.
args = %W[
--prefix=#{prefix}
--with-extra-functionsdir=#{HOMEBREW_PREFIX}/share/fish/vendor_functions.d
--with-extra-completionsdir=#{HOMEBREW_PREFIX}/share/fish/vendor_completions.d
--with-extra-confdir=#{HOMEBREW_PREFIX}/share/fish/vendor_conf.d
SED=/usr/bin/sed
]
system "./configure", *args
system "make", "install"
end
def caveats; <<~EOS
You will need to add:
#{HOMEBREW_PREFIX}/bin/fish
to /etc/shells.
Then run:
chsh -s #{HOMEBREW_PREFIX}/bin/fish
to make fish your default shell.
EOS
end
def post_install
(pkgshare/"vendor_functions.d").mkpath
(pkgshare/"vendor_completions.d").mkpath
(pkgshare/"vendor_conf.d").mkpath
end
test do
system "#{bin}/fish", "-c", "echo"
end
end

5
test/remove_sdkman.sh Normal file
View file

@ -0,0 +1,5 @@
#!/usr/bin/env bash
rm -rf "${HOME}/.sdkman" \
&& sed -i'.bak' -E -e 's/^.*(sdkman|SDKMAN).*$//g' "${HOME}/.bashrc" \
&& echo 'SDKMAN! uninstalled'

View file

@ -15,8 +15,14 @@ set check_count (math "3 * $test_count")
set sdk_init "$HOME/.sdkman/bin/sdkman-init.sh" set sdk_init "$HOME/.sdkman/bin/sdkman-init.sh"
function checksum -a file if [ (uname) = "Linux" ]
sha256sum $file | cut -d " " -f 1 function checksum -a file
sha256sum $file | cut -d " " -f 1
end
else # assume macOS
function checksum -a file
shasum -a 256 $file | cut -d " " -f 1
end
end end
echo "Testing the sdk wrapper" echo "Testing the sdk wrapper"