From 259b8effcfa6171a0f0fbd3dcf3737485d346906 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Thu, 11 Apr 2024 02:44:03 +0200 Subject: [PATCH] gnulib-tool.sh: Handle .gitignore files that do not end in a newline. * gnulib-tool.sh (func_import): If the .gitignore file ends with a character other than a newline, add a newline before adding more lines. --- ChangeLog | 6 ++++++ gnulib-tool.sh | 3 +++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index ac263c611f..4504a32681 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2024-04-10 Bruno Haible + + gnulib-tool.sh: Handle .gitignore files that do not end in a newline. + * gnulib-tool.sh (func_import): If the .gitignore file ends with a + character other than a newline, add a newline before adding more lines. + 2024-04-10 Bruno Haible gnulib-tool.py: Skip nonexistent modules instead of failing. diff --git a/gnulib-tool.sh b/gnulib-tool.sh index a8075d991f..e99b8fff79 100755 --- a/gnulib-tool.sh +++ b/gnulib-tool.sh @@ -6263,6 +6263,9 @@ s,//*$,/,' if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi } > "$tmp"/sed-ignore-removed { cat "$destdir/$dir$ignore"~ + # Add a newline if the original $dir$ignore file ended + # with a character other than a newline. + if test `tail -c 1 < "$destdir/$dir$ignore"~ | tr -d '\n' | wc -c` = 1; then echo; fi sed -e "s|^|$anchor|" < "$tmp"/ignore-added } | sed -f "$tmp"/sed-ignore-removed \ > "$destdir/$dir$ignore" -- 2.39.5