-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Environment: Ubuntu 24.04, uutils main branch (git commit 2afab7c), GNU coreutils 9.6.16-3f7c3-modified.
Steps to reproduce:
echo x > fx
echo y > fy
cat fx fy 1<>fx
(1<>fx means open file fx for both reading and writing in file descriptor 1.)
What happens now: uutils cat terminates with an error message:
cat: fx: input file is output file
and it has replaced the contents of the file fx with y\n.
What I expected to happen: GNU cat succeeds with no output and replaced the contents of the file fx with x\ny\n.
Notes: this is causing a failure in the GNU test file tests/cat/cat-self.sh. Also related to #7165. Contrast this behavior with GNU cat when the second file is redirected to file descriptor 1 instead of the first file:
cat fx fy 1<>fy
In this case, it terminates with error message cat: fy: input file is output file and it has replaced the contents of the file fy with x\n.