bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: Collin Funk <collin.funk1@gmail.com>, bug-gnulib@gnu.org
Subject: gnulib-tool.sh in time
Date: Thu, 11 Apr 2024 02:44:16 +0200	[thread overview]
Message-ID: <13014589.rXinls7zbI@nimes> (raw)

In the 'time' package, a .gitignore file does not end with a newline. And
while gnulib-tool.py adds a newline before adding more lines, gnulib.tool.sh
does not.

How to reproduce:

$ git clone https://git.savannah.gnu.org/git/time.git
$ cd time
Remove the duplicate /build-aux line from .gitignore.
$ GNULIB_TOOL_IMPL=sh ./bootstrap --no-git --gnulib-srcdir=$GNULIB_SRCDIR
Look at the last lines of .gitignore.

This patch fixes it.


2024-04-10  Bruno Haible  <bruno@clisp.org>

	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.

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"





                 reply	other threads:[~2024-04-11  0:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=13014589.rXinls7zbI@nimes \
    --to=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    --cc=collin.funk1@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).