From 092cfdcaf67f7b51af347dadad517ac6d6d9877d Mon Sep 17 00:00:00 2001 From: Typas Liao Date: Sun, 10 May 2026 22:57:12 +0800 Subject: [PATCH] fix(justfile): skip real dirs in _common-setup link loop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `_common-setup` linked every entry under `home/` and `config/` with `ln -sf`, which fails when the destination is a populated real directory (e.g. `~/.config/doom`, `~/.config/emacs`) — `unlink()` cannot remove a directory, so the recipe aborted. Guard each iteration: if the destination already exists as a real directory (not a symlink), print `skip (real dir)` and continue. Use `-snf` so dangling symlink-to-dir cases are also replaced cleanly. The `for f in "$root/home/".*` loop now uses a `case` filter for `.`/`..` rather than the previous compound test that interacts poorly with `set -e`. --- justfile | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/justfile b/justfile index 3c1d75e..5ea3198 100644 --- a/justfile +++ b/justfile @@ -52,16 +52,23 @@ _common-setup: set -euo pipefail cd "$HOME" for f in "{{root}}/home/".*; do - if [ "${f##*/}" != "." ] && [ "${f##*/}" != ".." ]; then - echo "Linking $f" - ln -sf "$f" . + name="${f##*/}" + case "$name" in .|..) continue;; esac + if [ -d "$name" ] && [ ! -L "$name" ]; then + echo "skip $name (real dir)"; continue fi + echo "Linking $f" + ln -snf "$f" . done mkdir -p "$HOME/.config" cd "$HOME/.config" for d in "{{root}}/config/"*/; do + name="$(basename "$d")" + if [ -d "$name" ] && [ ! -L "$name" ]; then + echo "skip $name (real dir)"; continue + fi echo "Linking $d" - ln -sf "$d" . + ln -snf "$d" . done _parallel-fonts scope: