Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: unset all enviroment variables ASDF_{PLUGIN}_VERSION #1632

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Changes from 9 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a770be4
feat: unset all enviroment variavles
edvardsanta Sep 6, 2023
7bb968a
uupdate: removed whitespaces
edvardsanta Sep 6, 2023
79906e7
Merge branch 'master' into add-unset-all
edvardsanta Sep 6, 2023
c876fef
Merge branch 'master' into add-unset-all
edvardsanta Sep 11, 2023
f840b8b
update: pr adjustments
edvardsanta Sep 11, 2023
98f2176
update: lint fix
edvardsanta Sep 11, 2023
06cad94
Merge branch 'master' into add-unset-all
edvardsanta Sep 12, 2023
d55b53a
update: unset_all is now on the top
edvardsanta Sep 12, 2023
5acb205
fix: lint update
edvardsanta Sep 12, 2023
3bcf682
tests: created tests
edvardsanta Sep 19, 2023
ab330e9
update: lint
edvardsanta Sep 19, 2023
fb3245f
ls ASDF DIR
edvardsanta Sep 19, 2023
4080b8e
update: check output of the tests
edvardsanta Sep 20, 2023
e540d19
test: new test with ruby
edvardsanta Sep 21, 2023
d06bfe5
update: doing ls before trying source
edvardsanta Sep 21, 2023
e62389c
changed copy
edvardsanta Sep 21, 2023
672d5ef
removed ls
edvardsanta Sep 21, 2023
b64ea50
Merge branch 'master' into add-unset-all
edvardsanta Sep 21, 2023
1b3f40d
update: create a specific function to source asdf
edvardsanta Sep 21, 2023
0786467
i found the function where tests shell
edvardsanta Sep 21, 2023
65a0978
adjusted test_helpers
edvardsanta Sep 21, 2023
d78468a
removed comment in other test
edvardsanta Sep 21, 2023
67b3220
legacy dummy changed
edvardsanta Sep 21, 2023
29818f3
removed tests to see workflow
edvardsanta Sep 22, 2023
bcb4403
added tests again
edvardsanta Sep 22, 2023
471d2d3
Merge branch 'master' into add-unset-all
edvardsanta Dec 4, 2023
8a7c0c4
Merge branch 'master' into add-unset-all
edvardsanta Mar 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions lib/commands/command-export-shell-version.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,49 @@
# shellcheck source=lib/functions/versions.bash
. "$(dirname "$(dirname "$0")")/lib/functions/versions.bash"

unset_all_fish() {
printf "for var in (env | awk -F= '/^ASDF_[A-Za-z0-9_]+_VERSION=/ {print \$1}')\n"
printf " echo Removing Env: \$var\n"
printf " set -e \$var\n"
printf "end\n"
}
unset_all() {
printf "for var in \$(env | awk -F= '/^ASDF_[A-Za-z0-9_]+_VERSION=/ {print \$1}'); do\n"
printf " echo Removing Env: "
printf " \$var\n"
printf " unset -v \$var\n"
printf "done\n"
}

# Output from this command must be executable shell code
shell_command() {
local asdf_shell="$1"
shift

if [ "$1" = '--unset-all' ]; then
case "$asdf_shell" in
fish)
unset_all_fish
;;
elvish)
# TODO
printf "asdf: Flag '--unset-all' not implemented for Elvish shell" >&2
;;
*)
unset_all
;;
esac
exit 0
fi

if [ "$#" -lt "2" ]; then
printf "Usage: asdf shell <name> {<version>|--unset}\n" >&2
printf "Usage: asdf shell {<name> {<version>|--unset}|--unset-all}\n" >&2
printf "false\n"
exit 1
fi

local plugin=$1
local version=$2

local upcase_name
upcase_name=$(tr '[:lower:]-' '[:upper:]_' <<<"$plugin")
local version_env_var="ASDF_${upcase_name}_VERSION"
Expand Down