Skip to content

Commit

Permalink
fix: improve readability of the non-set nullglob guard (#1545)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperupcall committed Apr 17, 2023
1 parent b36ec73 commit f273612
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions lib/commands/command-plugin-remove.bash
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,13 @@ plugin_remove_command() {
rm -rf "$(asdf_data_dir)/installs/${plugin_name}"
rm -rf "$(asdf_data_dir)/downloads/${plugin_name}"

local is_nullglob_disabled=
shopt -q nullglob || is_nullglob_disabled=yes
shopt -s nullglob
for f in "$(asdf_data_dir)"/shims/*; do
if grep -q "asdf-plugin: ${plugin_name}" "$f"; then
rm -f "$f"
if [ -f "$f" ]; then # nullglob may not be set
if grep -q "asdf-plugin: ${plugin_name}" "$f"; then
rm -f "$f"
fi
fi
done
[ "$is_nullglob_disabled" = 'yes' ] && shopt -u nullglob
unset -v is_nullglob_disabled

asdf_run_hook "post_asdf_plugin_remove" "$plugin_name"
asdf_run_hook "post_asdf_plugin_remove_${plugin_name}"
Expand Down

0 comments on commit f273612

Please sign in to comment.