From 8eb103d4548c7f4fc5e2ee058b33e5e552315027 Mon Sep 17 00:00:00 2001 From: gnekt Date: Tue, 24 Mar 2026 12:29:26 +0100 Subject: [PATCH] Use robust string matching and printf for user-mutable refs - Replace grep -qw with bash substring match for filename detection - Replace echo with printf '%s\n' to prevent content mangling --- scripts/launchme.sh | 2 +- scripts/updateme.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/launchme.sh b/scripts/launchme.sh index d352d8e..8b36144 100755 --- a/scripts/launchme.sh +++ b/scripts/launchme.sh @@ -129,7 +129,7 @@ for ref in "$REPO_DIR/references/"*.md; do ref_name="$(basename "$ref")" # On reinstall, preserve user-mutable reference files if [[ $EXISTING -eq 1 && -f "$VAULT_DIR/.claude/references/$ref_name" ]]; then - if echo "$USER_MUTABLE_REFS" | grep -qw "$ref_name"; then + if [[ " $USER_MUTABLE_REFS " == *" $ref_name "* ]]; then warn "Preserving existing $ref_name (run updateme.sh to merge upstream changes)" echo "$ref_name" >> "$VAULT_DIR/.claude/references/.core-manifest" continue diff --git a/scripts/updateme.sh b/scripts/updateme.sh index c9648d6..4484c41 100755 --- a/scripts/updateme.sh +++ b/scripts/updateme.sh @@ -159,7 +159,7 @@ for ref in "$REPO_DIR/references/"*.md; do vault_copy="$VAULT_DIR/.claude/references/$name" # For user-mutable files: preserve custom agent content - if echo "$USER_MUTABLE_REFS" | grep -qw "$name" && [[ -f "$vault_copy" ]]; then + if [[ " $USER_MUTABLE_REFS " == *" $name "* ]] && [[ -f "$vault_copy" ]]; then # Extract user's custom section (from "## Custom Agents" to end of file) custom_section="" if grep -qn "^## Custom Agents" "$vault_copy"; then @@ -200,7 +200,7 @@ for ref in "$REPO_DIR/references/"*.md; do repo_custom_line=$(grep -n "^## Custom Agents" "$vault_copy" | head -1 | cut -d: -f1) if [[ -n "$repo_custom_line" ]]; then head -n "$((repo_custom_line - 1))" "$vault_copy" > "$vault_copy.tmp" - echo "$custom_section" >> "$vault_copy.tmp" + printf '%s\n' "$custom_section" >> "$vault_copy.tmp" mv "$vault_copy.tmp" "$vault_copy" fi fi