From be2e606fbdbd8d129563a73a588e33e4fe350665 Mon Sep 17 00:00:00 2001 From: Jeff Kowalski Date: Thu, 6 Apr 2017 23:55:48 -0700 Subject: [PATCH 1/2] Prefer 'set' over 'setenv' for fish shell The setenv function in fish shell has changed dramatically in https://github.com/fish-shell/fish-shell/commit/75600b6b538f242a6b340e51965f25cfd4473c4a It now conforms to the csh version, which takes at most two arguments. In this init script, the form setenv PATH prepend_something $PATH had been used, which had too many arguments. Since setenv isn't a native command in fish, a suitable replacement is to use the "set -gx" command, which can consume multiple arguments. --- libexec/rbenv-init | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libexec/rbenv-init b/libexec/rbenv-init index ac9d4cf0..e8ae8d5a 100755 --- a/libexec/rbenv-init +++ b/libexec/rbenv-init @@ -86,8 +86,8 @@ mkdir -p "${RBENV_ROOT}/"{shims,versions} case "$shell" in fish ) - echo "setenv PATH '${RBENV_ROOT}/shims' \$PATH" - echo "setenv RBENV_SHELL $shell" + echo 'set -gx PATH '${RBENV_ROOT}'/shims $PATH' + echo "set -gx RBENV_SHELL $shell" ;; * ) echo 'export PATH="'${RBENV_ROOT}'/shims:${PATH}"' From a81da8d864c46c82b8d4ddc8da778f2cdf4274dd Mon Sep 17 00:00:00 2001 From: Jeff Kowalski Date: Tue, 16 May 2017 13:36:06 -0700 Subject: [PATCH 2/2] Revert quoting change in previous commit; adjust test to match code Revert back to original quoting style used before previous commit. Adjust init.bats to reflect changes for successful tests. --- libexec/rbenv-init | 2 +- test/init.bats | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) mode change 100644 => 100755 test/init.bats diff --git a/libexec/rbenv-init b/libexec/rbenv-init index e8ae8d5a..1661a052 100755 --- a/libexec/rbenv-init +++ b/libexec/rbenv-init @@ -86,7 +86,7 @@ mkdir -p "${RBENV_ROOT}/"{shims,versions} case "$shell" in fish ) - echo 'set -gx PATH '${RBENV_ROOT}'/shims $PATH' + echo "set -gx PATH '${RBENV_ROOT}/shims' \$PATH" echo "set -gx RBENV_SHELL $shell" ;; * ) diff --git a/test/init.bats b/test/init.bats old mode 100644 new mode 100755 index 95be301c..6cf64e8b --- a/test/init.bats +++ b/test/init.bats @@ -73,7 +73,7 @@ OUT export PATH="${BATS_TEST_DIRNAME}/../libexec:/usr/bin:/bin:/usr/local/bin" run rbenv-init - fish assert_success - assert_line 0 "setenv PATH '${RBENV_ROOT}/shims' \$PATH" + assert_line 0 "set -gx PATH '${RBENV_ROOT}/shims' \$PATH" } @test "can add shims to PATH more than once" { @@ -87,7 +87,7 @@ OUT export PATH="${RBENV_ROOT}/shims:$PATH" run rbenv-init - fish assert_success - assert_line 0 "setenv PATH '${RBENV_ROOT}/shims' \$PATH" + assert_line 0 "set -gx PATH '${RBENV_ROOT}/shims' \$PATH" } @test "outputs sh-compatible syntax" {