diff --git a/lib/commands/command-export-shell-version b/lib/commands/command-export-shell-version index ed3ea44a..bcc58730 100644 --- a/lib/commands/command-export-shell-version +++ b/lib/commands/command-export-shell-version @@ -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 diff --git a/test/version_commands.bats b/test/version_commands.bats index b393583b..00e21bee 100644 --- a/test/version_commands.bats +++ b/test/version_commands.bats @@ -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" ] +}