Merge pull request #640 from asdf-vm/improve-export-shell

Fix asdf shell xx --unset for fish
This commit is contained in:
Trevor Brown 2020-02-04 08:17:54 -05:00 committed by GitHub
commit f787b719ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -19,7 +19,14 @@ shell_command() {
local version_env_var="ASDF_${upcase_name}_VERSION"
if [ "$version" = "--unset" ]; then
echo "unset $version_env_var"
case "$asdf_shell" in
fish)
echo "set -e $version_env_var"
;;
*)
echo "unset $version_env_var"
;;
esac
exit 0
fi
if ! (check_if_version_exists "$plugin" "$version"); then

View File

@ -282,3 +282,15 @@ teardown() {
[ "$status" -eq 0 ]
[ "$output" = "set -gx ASDF_DUMMY_VERSION \"1.1.0\"" ]
}
@test "export-shell-version should unset when --unset flag is passed" {
run asdf export-shell-version sh "dummy" "--unset"
[ "$status" -eq 0 ]
[ "$output" = "unset ASDF_DUMMY_VERSION" ]
}
@test "export-shell-version should use set -e when --unset flag is passed and shell is fish" {
run asdf export-shell-version fish "dummy" "--unset"
[ "$status" -eq 0 ]
[ "$output" = "set -e ASDF_DUMMY_VERSION" ]
}