chore(bootstrap): optimize shell-scripts for robustness

This commit is contained in:
js0ny 2025-02-27 03:02:55 +00:00
parent 42b83d4696
commit 2c014e281f
13 changed files with 441 additions and 184 deletions

View file

@ -9,21 +9,21 @@ source "$DOTFILES/bootstrap/components/symlinks.bash"
echo "[INFO] DOTFILES = $DOTFILES"
echo "[ACTION] Press any key to proceed"
read -n 1
read -r -n1 -s
echo "[INFO] Setting up symbolic links"
for src in "${!linkDots[@]}"; do
dest="${linkDots[$src]}"
echo "Linking $src to $dest"
if [ -d "$src" ]; then
test -d "$dest" && mv "$dest" "$dest.bak"
ln -sf "$src" "$dest"
elif [ -f "$src" ]; then
dest_parent=$(dirname "$dest")
test -d "$dest_parent" || mkdir -p "$dest_parent"
ln -sf "$src" "$dest"
else
echo "[ERROR] $src does not exist"
fi
dest="${linkDots[$src]}"
echo "Linking $src to $dest"
if [ -d "$src" ]; then
test -d "$dest" && mv "$dest" "$dest.bak"
ln -sf "$src" "$dest"
elif [ -f "$src" ]; then
dest_parent=$(dirname "$dest")
test -d "$dest_parent" || mkdir -p "$dest_parent"
ln -sf "$src" "$dest"
else
echo "[ERROR] $src does not exist"
fi
done