From 1a207ff3a88453a1f2d47db14203e3ad5a8369b1 Mon Sep 17 00:00:00 2001 From: "Lockszmith (@VAST)" Date: Wed, 12 Mar 2025 17:29:39 -0400 Subject: [PATCH] Fix symclone to skip remove_ / *.tmpl extensions when testing existance --- symclone.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/symclone.sh b/symclone.sh index c762bb8..e25899b 100755 --- a/symclone.sh +++ b/symclone.sh @@ -57,11 +57,18 @@ relpath() { find "$SRC_DIR" -type f | while read -r file; do # Determine the relative path for the symlink target_file="${file#$SRC_DIR/}" + target_path="$DEST_DIR/${target_file}" + remove_target="${target_path%/*}/remove_$(<<<"${target_file##*/}" sed -Ee 's/^(symlink|executable)_//; s/(\.tmpl)$//;')" src_relative_path=$(relpath "$file" "$(dirname "$DEST_DIR/$target_file")") # Create the symlink with relative path - [ -L "$DEST_DIR/$target_file" ] || ! [ -e "$DEST_DIR/$target_file" ] \ - && ln ${FORCE} -vs "$src_relative_path" "$DEST_DIR/$target_file" + SKIP= + + [ -z "$SKIP" ] && [ -e "${remove_target}" ] && SKIP="remove entry found for: %s" || true + [ -z "$SKIP" ] && [ -L "$target_path" ] && [ -z "$FORCE" ] && SKIP="can't force replace %s" || true + [ -z "$SKIP" ] && [ -e "$target_path" ] && SKIP="%s exists" || true + [ -n "$DBG" ] && [ -n "$SKIP" ] && printf "$SKIP\n" "$target_path" || true + [ -n "$SKIP" ] || ln ${FORCE} -vs "$src_relative_path" "$target_path" || (set | grep -E '^(?:target|remove|src)_' >&2; false) done echo "Symbolic links created successfully in '$DEST_DIR'."