bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#18449: "cat x >> x" error even when x is empty


From: Vincent Lefevre
Subject: bug#18449: "cat x >> x" error even when x is empty
Date: Thu, 11 Sep 2014 15:00:44 +0200
User-agent: Mutt/1.5.23-6361-vl-r59709 (2014-07-25)

With coreutils 8.23 under Debian/unstable:

ypig% : > x
ypig% cat x >> x
cat: x: input file is output file
ypig% POSIXLY_CORRECT=1 cat x >> x
cat: x: input file is output file

while there's no reason to return an error in this case: the file
should just remain empty. Using the same file for input and output
isn't disallowed by POSIX, AFAIK.

This may not seem really useful here, but this can potentially break
scripts with things like:

  cat "$foo" >> "$bar"

where "$foo" may be the same file as "$bar" only if it is empty.

BTW, when x isn't empty, I wonder whether an error is correct if
POSIXLY_CORRECT is set. The result will typically depend on the
implementation and possibly be non-deterministic, but POSIX doesn't
seem to allow an error (except FS errors, such as disk full).

-- 
Vincent Lefèvre <address@hidden> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]