From f273612155188f62cf8daf584d5581cd4214daf4 Mon Sep 17 00:00:00 2001 From: Edwin Kofler Date: Sun, 16 Apr 2023 21:51:06 -0700 Subject: [PATCH] fix: improve readability of the non-set `nullglob` guard (#1545) --- lib/commands/command-plugin-remove.bash | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/commands/command-plugin-remove.bash b/lib/commands/command-plugin-remove.bash index 6441c665e..7b959bdf7 100644 --- a/lib/commands/command-plugin-remove.bash +++ b/lib/commands/command-plugin-remove.bash @@ -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}"