[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnulib-tool: In sh+py mode, don't fail because of dangling symlinks
From: |
Bruno Haible |
Subject: |
gnulib-tool: In sh+py mode, don't fail because of dangling symlinks |
Date: |
Sun, 21 Apr 2024 00:31:48 +0200 |
Paul Eggert reported:
> I tried this on my well-worn copy of GNU diffutils, and got the
> following diagnostics. These were all diagnostics about backup files, or
> files I manually deleted by moving them into a '.del' subdirectory (an
> old habit of mine), or symlink loops that I had created to test.
>
> Perhaps the advice should start with, "Start with a fresh checkout from
> Git."
>
> -----
> diff: ./.del/gnulib-tests/test-fnmatch-1.sh: No such file or directory
> diff: /home/eggert/src/gnu/glpyXeRWfy/.del/gnulib-tests/test-fnmatch-1.sh: No
> such file or directory
> ...
These old files most likely were not backup files, but dangling symlinks.
With dangling symlinks, I can reproduce the error, and this patch fixes it:
2024-04-20 Bruno Haible <bruno@clisp.org>
gnulib-tool: In sh+py mode, don't fail because of dangling symlinks.
Reported by Paul Eggert in
<https://lists.gnu.org/archive/html/bug-gnulib/2024-04/msg00318.html>
and Pádraig Brady in
<https://lists.gnu.org/archive/html/bug-gnulib/2024-04/msg00321.html>.
* gnulib-tool: In sh+py mode, use diff option '--no-dereference' if
available.
diff --git a/gnulib-tool b/gnulib-tool
index d7b6d33912..6d430e56e6 100755
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -192,7 +192,14 @@ case "$GNULIB_TOOL_IMPL" in
func_fatal_error "gnulib-tool.sh succeeded but gnulib-tool.py
failed! Inspect $tmp/ and $tmp-py-err."
fi
# Compare the two results on the file system.
- diff -r -q . "$tmp" >/dev/null ||
+ # GNU diffutils 3.3 or newer support option --no-dereference. This
+ # option avoids errors on dangling links.
+ if LC_ALL=C diff --help 2>/dev/null | grep no-dereference >/dev/null;
then
+ diff_options='--no-dereference'
+ else
+ diff_options=
+ fi
+ diff -r $diff_options -q . "$tmp" >/dev/null ||
func_fatal_error "gnulib-tool.py produced different files than
gnulib-tool.sh! Compare `pwd` and $tmp."
# Compare the two outputs.
diff -q "$tmp-sh-out" "$tmp-py-out" >/dev/null ||
@@ -235,7 +242,14 @@ case "$GNULIB_TOOL_IMPL" in
func_fatal_error "gnulib-tool.sh succeeded but gnulib-tool.py
failed! Inspect $tmp/ and $tmp-py-err."
fi
# Compare the two results on the file system.
- diff -r -q "$dir" "$tmp" >/dev/null ||
+ # GNU diffutils 3.3 or newer support option --no-dereference. This
+ # option avoids errors on dangling links.
+ if LC_ALL=C diff --help 2>/dev/null | grep no-dereference >/dev/null;
then
+ diff_options='--no-dereference'
+ else
+ diff_options=
+ fi
+ diff -r $diff_options -q "$dir" "$tmp" >/dev/null ||
func_fatal_error "gnulib-tool.py produced different files than
gnulib-tool.sh! Compare $dir and $tmp."
# Compare the two outputs.
diff -q "$tmp-sh-out" "$tmp-py-out" >/dev/null ||
- beta-tester call draft, Bruno Haible, 2024/04/19
- Re: beta-tester call draft, Bruno Haible, 2024/04/19
- Re: beta-tester call draft, Collin Funk, 2024/04/19
- Re: beta-tester call draft, Paul Eggert, 2024/04/20
- gnulib-tool: In sh+py mode, don't fail because of dangling symlinks,
Bruno Haible <=
- Re: beta-tester call draft, Bruno Haible, 2024/04/20
- Re: beta-tester call draft, Simon Josefsson, 2024/04/20
Re: beta-tester call draft, Pádraig Brady, 2024/04/20
Re: beta-tester call draft, Bernhard Voelker, 2024/04/20