On 15/02/2025 06:22, Paul Eggert wrote:
On 2025-02-12 22:45, lilydjwg wrote:
cat: -: input file is output file
Thanks for the bug report. The symptoms you observe are a bug in 'cat'.
I also see a bug in Gawk which I reported to the Gawk maintainer
<https://lists.gnu.org/r/bug-gawk/2025-02/msg00003.html>. I don't see a
bug in zsh or fish but perhaps I'm missing something.
To fix the 'cat' bug I installed the attached patch into bleeding-edge
Coreutils on Savannah, and something like this patch should appear in
the next release.
From my TODO list, attached is a test case for this issue.
I'll push this tomorrow some time.
cheers,
Pádraig
From 8771957703cf4f8d71f2d04ef0614d2aeb0c65ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <p...@draigbrady.com>
Date: Tue, 1 Jul 2025 22:52:16 +0100
Subject: [PATCH] tests: cat: add test for O_APPEND bug fix
* tests/cat/cat-self.sh: Add a test case
for commit v9.6-19-g7386c291b
---
tests/cat/cat-self.sh | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/tests/cat/cat-self.sh b/tests/cat/cat-self.sh
index 3c171b40b..2d09fc087 100755
--- a/tests/cat/cat-self.sh
+++ b/tests/cat/cat-self.sh
@@ -50,4 +50,14 @@ returns_ 1 cat - fx4 <fx 1<>fx4 || fail=1
returns_ 1 cat fx5 >>fx5 || fail=1
returns_ 1 cat <fx6 >>fx6 || fail=1
+# coreutils 9.6 would fail with a plain cat if the tty was in append mode
+# Simulate with a regular file to simplify
+echo foo > file || framework_failure_
+# Set fd 3 at EOF
+exec 3< file && cat <&3 > /dev/null || framework_failure_
+# Set fd 4 in append mode
+exec 4>> file || framework_failure_
+cat <&3 >&4 || fail=1
+exec 3<&- 4>&-
+
Exit $fail
--
2.49.0