fix: harden installer symlink logic and interactive sourcing #1

Merged
dschlueter merged 1 commit from fix/installer-strict-mode into main 2026-06-28 03:49:13 +02:00
2 changed files with 9 additions and 2 deletions

View file

@ -11,7 +11,12 @@ ALIAS_LINE="source $TARGET_REPO/shell/aliases.sh"
mkdir -p "$TARGET_DIR" mkdir -p "$TARGET_DIR"
if [[ "$REPO_DIR" != "$TARGET_REPO" ]]; then 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" ln -s "$REPO_DIR" "$TARGET_REPO"
fi fi
fi fi

View file

@ -1,5 +1,7 @@
#!/usr/bin/env bash #!/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() { repo_root() {
local script_dir local script_dir