From 35b2da39d27942f865ee22735de359e21168f9fa Mon Sep 17 00:00:00 2001 From: dschlueter Date: Sun, 28 Jun 2026 03:23:03 +0200 Subject: [PATCH] fix: harden installer symlink logic and interactive sourcing - install-claude-profiles: distinguish broken symlink vs real dir vs free path via -L/-e, repoint existing links with ln -sfn, warn instead of silently skipping when target is a non-symlink dir. - profiles.sh: only set -euo pipefail when sourced non-interactively so sourcing in an interactive shell doesn't clobber session settings. Co-Authored-By: Claude --- bin/install-claude-profiles | 7 ++++++- lib/profiles.sh | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/install-claude-profiles b/bin/install-claude-profiles index 3c519de..e7b78f1 100755 --- a/bin/install-claude-profiles +++ b/bin/install-claude-profiles @@ -11,7 +11,12 @@ ALIAS_LINE="source $TARGET_REPO/shell/aliases.sh" mkdir -p "$TARGET_DIR" if [[ "$REPO_DIR" != "$TARGET_REPO" ]]; then - if [[ ! -e "$TARGET_REPO" ]]; then + if [[ -L "$TARGET_REPO" ]]; then + ln -sfn "$REPO_DIR" "$TARGET_REPO" + elif [[ -e "$TARGET_REPO" ]]; then + echo "Warning: $TARGET_REPO exists and is not a symlink;" >&2 + echo " aliases will point there. Remove it to repoint to $REPO_DIR." >&2 + else ln -s "$REPO_DIR" "$TARGET_REPO" fi fi diff --git a/lib/profiles.sh b/lib/profiles.sh index 5f4159b..73575cc 100755 --- a/lib/profiles.sh +++ b/lib/profiles.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash -set -euo pipefail +# Only enforce strict mode when sourced non-interactively, so sourcing this +# file in an interactive shell doesn't clobber the user's session settings. +[[ $- == *i* ]] || set -euo pipefail repo_root() { local script_dir