Skip to content

Commit 07a2db8

Browse files
Merge pull request #1 from LucaTools/allow-path-uploading
Allow `.luca/active` path unloading
2 parents 9c81bb9 + 87a5384 commit 07a2db8

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

shell_hook.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,28 @@ update_path() {
5151
# echo "$TOOL_NAME: Added $tool_bin_dir to PATH"
5252
;;
5353
esac
54+
else
55+
# If the directory doesn't exist, remove any stale tool entries from PATH
56+
if [[ ":$PATH:" == *"/$TOOL_FOLDER/active:"* ]]; then
57+
local p
58+
local new_path=""
59+
local current_path="$PATH"
60+
61+
while [ -n "$current_path" ]; do
62+
p="${current_path%%:*}"
63+
64+
if [ "$current_path" = "$p" ]; then
65+
current_path=""
66+
else
67+
current_path="${current_path#*:}"
68+
fi
69+
70+
if [[ "$p" != *"/$TOOL_FOLDER/active" ]]; then
71+
new_path="${new_path:+$new_path:}$p"
72+
fi
73+
done
74+
export PATH="$new_path"
75+
fi
5476
fi
5577
}
5678

0 commit comments

Comments
 (0)