From 8d4495d4bc62fc4695617e6d5cc62b47a6d43820 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 19 Apr 2026 12:46:32 -0500 Subject: fix(install): don't duplicate gitignore header on re-run --- scripts/install-lang.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'scripts/install-lang.sh') diff --git a/scripts/install-lang.sh b/scripts/install-lang.sh index 2ee4aa7..4097bde 100755 --- a/scripts/install-lang.sh +++ b/scripts/install-lang.sh @@ -79,6 +79,7 @@ fi # 4. .gitignore — append missing lines (deduped, skip comments) if [ -f "$SRC/gitignore-add.txt" ]; then touch "$PROJECT/.gitignore" + header="# --- $LANG ruleset ---" added=0 while IFS= read -r line || [ -n "$line" ]; do # Skip blank lines and comments in the source file @@ -86,9 +87,9 @@ if [ -f "$SRC/gitignore-add.txt" ]; then case "$line" in \#*) continue ;; esac # Only add if not already present if ! grep -qxF "$line" "$PROJECT/.gitignore"; then - # If this is the first line we're adding, prepend a header - if [ "$added" -eq 0 ]; then - printf '\n# --- %s ruleset ---\n' "$LANG" >> "$PROJECT/.gitignore" + # Prepend header only if it isn't already in the file + if [ "$added" -eq 0 ] && ! grep -qxF "$header" "$PROJECT/.gitignore"; then + printf '\n%s\n' "$header" >> "$PROJECT/.gitignore" fi echo "$line" >> "$PROJECT/.gitignore" added=$((added + 1)) -- cgit v1.2.3