refractor: Refractor zsh script that cannot be auto-formatted

This commit is contained in:
js0ny 2025-02-24 01:15:45 +00:00
parent ae04b4f626
commit 996a64042d

View file

@ -14,16 +14,16 @@ read -n 1
echo "[INFO] Setting up symbolic links" echo "[INFO] Setting up symbolic links"
# 使用 zsh 的关联数组语法 # 使用 zsh 的关联数组语法
for src in ${(k)linkDots}; do for src in ${(k)linkDots}; do
dest="${linkDots[$src]}" dest="${linkDots[$src]}"
echo "Linking $src to $dest" echo "Linking $src to $dest"
if [ -d "$src" ]; then if [ -d "$src" ]; then
test -d $dest && mv $dest $dest.bak test -d $dest && mv $dest $dest.bak
ln -sf $src $dest ln -sf $src $dest
elif [ -f "$src" ]; then elif [ -f "$src" ]; then
dest_parent=$(dirname $dest) dest_parent=$(dirname $dest)
test -d $dest_parent || mkdir -p $dest_parent test -d $dest_parent || mkdir -p $dest_parent
ln -sf $src $dest ln -sf $src $dest
else else
echo "[ERROR] $src does not exist" echo "[ERROR] $src does not exist"
fi fi
done done