Discussion:
[1003.1(2013)/Issue7+TC1 0000876]: allow implementations to fail on 'cat a >> a'
Austin Group Bug Tracker
2014-09-11 14:55:04 UTC
Permalink
The following issue has been SUBMITTED.
======================================================================
http://austingroupbugs.net/view.php?id=876
======================================================================
Reported By: eblake
Assigned To:
======================================================================
Project: 1003.1(2013)/Issue7+TC1
Issue ID: 876
Category: Shell and Utilities
Type: Omission
Severity: Objection
Priority: normal
Status: New
Name: Eric Blake
Organization: Red Hat
User Reference: eblake.cat
Section: cat
Page Number: 2526
Line Number: 81474
Interp Status: ---
Final Accepted Text:
======================================================================
Date Submitted: 2014-09-11 14:55 UTC
Last Modified: 2014-09-11 14:55 UTC
======================================================================
Summary: allow implementations to fail on 'cat a >> a'
Description:
Several existing implementations of cat explicitly refuse to output to the
same file descriptor as any of its inputs, to avoid filling up the disk if
the file is non-empty:

Solaris:
$ cd /tmp/
$ touch a
$ /usr/bin/cat a >> a
cat: input/output files 'a' identical

GNU:
$ cd /tmp/
$ touch a
$ cat a >> a
cat: a: input file is output file

This behavior doesn't seem to be permitted by the standard, although it is
useful. The proposal here only fixes cat, although the group may decide to
make the allowance for same input/output rejection have wider scope.
Desired Action:
At line 81474 [XCU cat STDOUT], add a sentence:
If the standard output is a regular file, and is the same file as any of
the input file operands, the implementation may treat this as an error
without writing anything to the output file.
======================================================================

Issue History
Date Modified Username Field Change
======================================================================
2014-09-11 14:55 eblake New Issue
2014-09-11 14:55 eblake Name => Eric Blake
2014-09-11 14:55 eblake Organization => Red Hat
2014-09-11 14:55 eblake User Reference => eblake.cat
2014-09-11 14:55 eblake Section => cat
2014-09-11 14:55 eblake Page Number => 2526
2014-09-11 14:55 eblake Line Number => 81474
2014-09-11 14:55 eblake Interp Status => ---
======================================================================
Austin Group Bug Tracker
2014-09-11 16:23:37 UTC
Permalink
A NOTE has been added to this issue.
======================================================================
http://austingroupbugs.net/view.php?id=876
======================================================================
Reported By: eblake
Assigned To:
======================================================================
Project: 1003.1(2013)/Issue7+TC1
Issue ID: 876
Category: Shell and Utilities
Type: Omission
Severity: Objection
Priority: normal
Status: New
Name: Eric Blake
Organization: Red Hat
User Reference: eblake.cat
Section: cat
Page Number: 2526
Line Number: 81474
Interp Status: ---
Final Accepted Text:
======================================================================
Date Submitted: 2014-09-11 14:55 UTC
Last Modified: 2014-09-11 16:23 UTC
======================================================================
Summary: allow implementations to fail on 'cat a >> a'
======================================================================

----------------------------------------------------------------------
(0002377) eblake (manager) - 2014-09-11 16:23
http://austingroupbugs.net/view.php?id=876#c2377
----------------------------------------------------------------------
Paul Eggert pointed out to me that the example at line 81508 may also need
updating:

Because of the shell language mechanism used to perform output redirection,
a command such as this:
cat doc doc.end > doc
causes the original data in doc to be lost.

On my test system, data was indeed lost
$ echo 1 > a
$ echo 2 > b
$ cat a b > a
cat: a: input file is output file
$ cat a
2

but it also demonstrates that cat merely skipped the processing of 'a',
rather than failing up front. So it may be better to document that an
input file is skipped if it is the same as the output (causing an overall
error), rather than my original proposed wording tied to the output file.

Issue History
Date Modified Username Field Change
======================================================================
2014-09-11 14:55 eblake New Issue
2014-09-11 14:55 eblake Name => Eric Blake
2014-09-11 14:55 eblake Organization => Red Hat
2014-09-11 14:55 eblake User Reference => eblake.cat
2014-09-11 14:55 eblake Section => cat
2014-09-11 14:55 eblake Page Number => 2526
2014-09-11 14:55 eblake Line Number => 81474
2014-09-11 14:55 eblake Interp Status => ---
2014-09-11 16:23 eblake Note Added: 0002377
======================================================================
Austin Group Bug Tracker
2014-09-11 16:27:54 UTC
Permalink
A NOTE has been added to this issue.
======================================================================
http://austingroupbugs.net/view.php?id=876
======================================================================
Reported By: eblake
Assigned To:
======================================================================
Project: 1003.1(2013)/Issue7+TC1
Issue ID: 876
Category: Shell and Utilities
Type: Omission
Severity: Objection
Priority: normal
Status: New
Name: Eric Blake
Organization: Red Hat
User Reference: eblake.cat
Section: cat
Page Number: 2526
Line Number: 81474
Interp Status: ---
Final Accepted Text:
======================================================================
Date Submitted: 2014-09-11 14:55 UTC
Last Modified: 2014-09-11 16:27 UTC
======================================================================
Summary: allow implementations to fail on 'cat a >> a'
======================================================================

----------------------------------------------------------------------
(0002378) eblake (manager) - 2014-09-11 16:27
http://austingroupbugs.net/view.php?id=876#c2378
----------------------------------------------------------------------
Arguably, using the fact that cat'ting a non-empty regular file to itself
will eventually fail due to the disk being full, one can argue that POSIX
already allows implementations to fail (and doesn't forbid from failing
early, rather than first exhausting the disk). After all, we justified the
reason that 'rm -rf /' is allowed to fail early rather than late based on
the fact that it will eventually fail when rm is itself removed, and
failing earlier is nicer if we can prove eventual failure would have
happened. But it then raises the issue of whether cat'ting an empty file
to itself is allowed to fail (since if permitted, it would not fill the
disk, therefore, we cannot prove that it would fail late, so it is harder
to justify it failing early).

Issue History
Date Modified Username Field Change
======================================================================
2014-09-11 14:55 eblake New Issue
2014-09-11 14:55 eblake Name => Eric Blake
2014-09-11 14:55 eblake Organization => Red Hat
2014-09-11 14:55 eblake User Reference => eblake.cat
2014-09-11 14:55 eblake Section => cat
2014-09-11 14:55 eblake Page Number => 2526
2014-09-11 14:55 eblake Line Number => 81474
2014-09-11 14:55 eblake Interp Status => ---
2014-09-11 16:23 eblake Note Added: 0002377
2014-09-11 16:27 eblake Note Added: 0002378
======================================================================
Austin Group Bug Tracker
2014-09-11 16:54:41 UTC
Permalink
A NOTE has been added to this issue.
======================================================================
http://austingroupbugs.net/view.php?id=876
======================================================================
Reported By: eblake
Assigned To:
======================================================================
Project: 1003.1(2013)/Issue7+TC1
Issue ID: 876
Category: Shell and Utilities
Type: Omission
Severity: Objection
Priority: normal
Status: New
Name: Eric Blake
Organization: Red Hat
User Reference: eblake.cat
Section: cat
Page Number: 2526
Line Number: 81474
Interp Status: ---
Final Accepted Text:
======================================================================
Date Submitted: 2014-09-11 14:55 UTC
Last Modified: 2014-09-11 16:54 UTC
======================================================================
Summary: allow implementations to fail on 'cat a >> a'
======================================================================

----------------------------------------------------------------------
(0002379) shware_systems (reporter) - 2014-09-11 16:54
http://austingroupbugs.net/view.php?id=876#c2379
----------------------------------------------------------------------
Would it be better to make explicit, for those file types where the size is
known when the operand is encountered, that cat shall only copy those size
bytes in number, regardless of target? This would have

cat a >> a

only doubling in size, not entering an infinite loop that exhausts the
disk. I believe this matches better the intent of the utility; copy this
chunk of data, as it is now, to standard output.

Issue History
Date Modified Username Field Change
======================================================================
2014-09-11 14:55 eblake New Issue
2014-09-11 14:55 eblake Name => Eric Blake
2014-09-11 14:55 eblake Organization => Red Hat
2014-09-11 14:55 eblake User Reference => eblake.cat
2014-09-11 14:55 eblake Section => cat
2014-09-11 14:55 eblake Page Number => 2526
2014-09-11 14:55 eblake Line Number => 81474
2014-09-11 14:55 eblake Interp Status => ---
2014-09-11 16:23 eblake Note Added: 0002377
2014-09-11 16:27 eblake Note Added: 0002378
2014-09-11 16:54 shware_systems Note Added: 0002379
======================================================================
Austin Group Bug Tracker
2014-09-11 17:02:09 UTC
Permalink
A NOTE has been added to this issue.
======================================================================
http://austingroupbugs.net/view.php?id=876
======================================================================
Reported By: eblake
Assigned To:
======================================================================
Project: 1003.1(2013)/Issue7+TC1
Issue ID: 876
Category: Shell and Utilities
Type: Omission
Severity: Objection
Priority: normal
Status: New
Name: Eric Blake
Organization: Red Hat
User Reference: eblake.cat
Section: cat
Page Number: 2526
Line Number: 81474
Interp Status: ---
Final Accepted Text:
======================================================================
Date Submitted: 2014-09-11 14:55 UTC
Last Modified: 2014-09-11 17:02 UTC
======================================================================
Summary: allow implementations to fail on 'cat a >> a'
======================================================================

----------------------------------------------------------------------
(0002380) eblake (manager) - 2014-09-11 17:02
http://austingroupbugs.net/view.php?id=876#c2380
----------------------------------------------------------------------
In response to http://austingroupbugs.net/view.php?id=876#c2379:
If we were designing from scratch, maybe. But it would render existing
implementations non-compliant; my argument here is to relax the standard to
allow existing behavior, not to mandate new behavior of only doubling in
size.

Issue History
Date Modified Username Field Change
======================================================================
2014-09-11 14:55 eblake New Issue
2014-09-11 14:55 eblake Name => Eric Blake
2014-09-11 14:55 eblake Organization => Red Hat
2014-09-11 14:55 eblake User Reference => eblake.cat
2014-09-11 14:55 eblake Section => cat
2014-09-11 14:55 eblake Page Number => 2526
2014-09-11 14:55 eblake Line Number => 81474
2014-09-11 14:55 eblake Interp Status => ---
2014-09-11 16:23 eblake Note Added: 0002377
2014-09-11 16:27 eblake Note Added: 0002378
2014-09-11 16:54 shware_systems Note Added: 0002379
2014-09-11 17:02 eblake Note Added: 0002380
======================================================================
Austin Group Bug Tracker
2014-09-11 17:33:58 UTC
Permalink
A NOTE has been added to this issue.
======================================================================
http://austingroupbugs.net/view.php?id=876
======================================================================
Reported By: eblake
Assigned To:
======================================================================
Project: 1003.1(2013)/Issue7+TC1
Issue ID: 876
Category: Shell and Utilities
Type: Omission
Severity: Objection
Priority: normal
Status: New
Name: Eric Blake
Organization: Red Hat
User Reference: eblake.cat
Section: cat
Page Number: 2526
Line Number: 81474
Interp Status: ---
Final Accepted Text:
======================================================================
Date Submitted: 2014-09-11 14:55 UTC
Last Modified: 2014-09-11 17:33 UTC
======================================================================
Summary: allow implementations to fail on 'cat a >> a'
======================================================================

----------------------------------------------------------------------
(0002381) Don Cragun (manager) - 2014-09-11 17:33
http://austingroupbugs.net/view.php?id=876#c2381
----------------------------------------------------------------------
Concerning http://austingroupbugs.net/view.php?id=876#c2377: The command: cat a
b > a
hoes not indicate that cat skipped the contents of a; the contents of a
were destroyed by the shell when it performed the requested redirection
before cat entered main().

Issue History
Date Modified Username Field Change
======================================================================
2014-09-11 14:55 eblake New Issue
2014-09-11 14:55 eblake Name => Eric Blake
2014-09-11 14:55 eblake Organization => Red Hat
2014-09-11 14:55 eblake User Reference => eblake.cat
2014-09-11 14:55 eblake Section => cat
2014-09-11 14:55 eblake Page Number => 2526
2014-09-11 14:55 eblake Line Number => 81474
2014-09-11 14:55 eblake Interp Status => ---
2014-09-11 16:23 eblake Note Added: 0002377
2014-09-11 16:27 eblake Note Added: 0002378
2014-09-11 16:54 shware_systems Note Added: 0002379
2014-09-11 17:02 eblake Note Added: 0002380
2014-09-11 17:33 Don Cragun Note Added: 0002381
======================================================================
Austin Group Bug Tracker
2014-09-11 17:42:51 UTC
Permalink
A NOTE has been added to this issue.
======================================================================
http://austingroupbugs.net/view.php?id=876
======================================================================
Reported By: eblake
Assigned To:
======================================================================
Project: 1003.1(2013)/Issue7+TC1
Issue ID: 876
Category: Shell and Utilities
Type: Omission
Severity: Objection
Priority: normal
Status: New
Name: Eric Blake
Organization: Red Hat
User Reference: eblake.cat
Section: cat
Page Number: 2526
Line Number: 81474
Interp Status: ---
Final Accepted Text:
======================================================================
Date Submitted: 2014-09-11 14:55 UTC
Last Modified: 2014-09-11 17:42 UTC
======================================================================
Summary: allow implementations to fail on 'cat a >> a'
======================================================================

----------------------------------------------------------------------
(0002382) eblake (manager) - 2014-09-11 17:42
http://austingroupbugs.net/view.php?id=876#c2382
----------------------------------------------------------------------
Ah, but:

$ echo 1 > a
$ echo 2 > b
$ echo 3 > c
$ cat a b c > b
cat: b: input file is output file
$ cat b
1
3

this time, the contents of 'b' are NOT empty at the time the error message
about b is produced.

Issue History
Date Modified Username Field Change
======================================================================
2014-09-11 14:55 eblake New Issue
2014-09-11 14:55 eblake Name => Eric Blake
2014-09-11 14:55 eblake Organization => Red Hat
2014-09-11 14:55 eblake User Reference => eblake.cat
2014-09-11 14:55 eblake Section => cat
2014-09-11 14:55 eblake Page Number => 2526
2014-09-11 14:55 eblake Line Number => 81474
2014-09-11 14:55 eblake Interp Status => ---
2014-09-11 16:23 eblake Note Added: 0002377
2014-09-11 16:27 eblake Note Added: 0002378
2014-09-11 16:54 shware_systems Note Added: 0002379
2014-09-11 17:02 eblake Note Added: 0002380
2014-09-11 17:33 Don Cragun Note Added: 0002381
2014-09-11 17:34 Don Cragun Note Edited: 0002381
2014-09-11 17:42 eblake Note Added: 0002382
======================================================================
Austin Group Bug Tracker
2014-09-12 06:30:50 UTC
Permalink
A NOTE has been added to this issue.
======================================================================
http://austingroupbugs.net/view.php?id=876
======================================================================
Reported By: eblake
Assigned To:
======================================================================
Project: 1003.1(2013)/Issue7+TC1
Issue ID: 876
Category: Shell and Utilities
Type: Omission
Severity: Objection
Priority: normal
Status: New
Name: Eric Blake
Organization: Red Hat
User Reference: eblake.cat
Section: cat
Page Number: 2526
Line Number: 81474
Interp Status: ---
Final Accepted Text:
======================================================================
Date Submitted: 2014-09-11 14:55 UTC
Last Modified: 2014-09-11 17:42 UTC
======================================================================
Summary: allow implementations to fail on 'cat a >> a'
======================================================================

----------------------------------------------------------------------
(0002382) eblake (manager) - 2014-09-11 17:42
http://austingroupbugs.net/view.php?id=876#c2382
----------------------------------------------------------------------
Ah, but:

$ echo 1 > a
$ echo 2 > b
$ echo 3 > c
$ cat a b c > b
cat: b: input file is output file
$ cat b
1
3

this time, the contents of 'b' are NOT empty at the time the error message
about b is produced.

Issue History
Date Modified Username Field Change
======================================================================
2014-09-11 14:55 eblake New Issue
2014-09-11 14:55 eblake Name => Eric Blake
2014-09-11 14:55 eblake Organization => Red Hat
2014-09-11 14:55 eblake User Reference => eblake.cat
2014-09-11 14:55 eblake Section => cat
2014-09-11 14:55 eblake Page Number => 2526
2014-09-11 14:55 eblake Line Number => 81474
2014-09-11 14:55 eblake Interp Status => ---
2014-09-11 16:23 eblake Note Added: 0002377
2014-09-11 16:27 eblake Note Added: 0002378
2014-09-11 16:54 shware_systems Note Added: 0002379
2014-09-11 17:02 eblake Note Added: 0002380
2014-09-11 17:33 Don Cragun Note Added: 0002381
2014-09-11 17:34 Don Cragun Note Edited: 0002381
2014-09-11 17:42 eblake Note Added: 0002382
======================================================================
Austin Group Bug Tracker
2014-09-12 06:31:00 UTC
Permalink
A NOTE has been added to this issue.
======================================================================
http://austingroupbugs.net/view.php?id=876
======================================================================
Reported By: eblake
Assigned To:
======================================================================
Project: 1003.1(2013)/Issue7+TC1
Issue ID: 876
Category: Shell and Utilities
Type: Omission
Severity: Objection
Priority: normal
Status: New
Name: Eric Blake
Organization: Red Hat
User Reference: eblake.cat
Section: cat
Page Number: 2526
Line Number: 81474
Interp Status: ---
Final Accepted Text:
======================================================================
Date Submitted: 2014-09-11 14:55 UTC
Last Modified: 2014-09-11 17:02 UTC
======================================================================
Summary: allow implementations to fail on 'cat a >> a'
======================================================================

----------------------------------------------------------------------
(0002380) eblake (manager) - 2014-09-11 17:02
http://austingroupbugs.net/view.php?id=876#c2380
----------------------------------------------------------------------
In response to http://austingroupbugs.net/view.php?id=876#c2379:
If we were designing from scratch, maybe. But it would render existing
implementations non-compliant; my argument here is to relax the standard to
allow existing behavior, not to mandate new behavior of only doubling in
size.

Issue History
Date Modified Username Field Change
======================================================================
2014-09-11 14:55 eblake New Issue
2014-09-11 14:55 eblake Name => Eric Blake
2014-09-11 14:55 eblake Organization => Red Hat
2014-09-11 14:55 eblake User Reference => eblake.cat
2014-09-11 14:55 eblake Section => cat
2014-09-11 14:55 eblake Page Number => 2526
2014-09-11 14:55 eblake Line Number => 81474
2014-09-11 14:55 eblake Interp Status => ---
2014-09-11 16:23 eblake Note Added: 0002377
2014-09-11 16:27 eblake Note Added: 0002378
2014-09-11 16:54 shware_systems Note Added: 0002379
2014-09-11 17:02 eblake Note Added: 0002380
======================================================================
Austin Group Bug Tracker
2014-09-12 06:31:05 UTC
Permalink
A NOTE has been added to this issue.
======================================================================
http://austingroupbugs.net/view.php?id=876
======================================================================
Reported By: eblake
Assigned To:
======================================================================
Project: 1003.1(2013)/Issue7+TC1
Issue ID: 876
Category: Shell and Utilities
Type: Omission
Severity: Objection
Priority: normal
Status: New
Name: Eric Blake
Organization: Red Hat
User Reference: eblake.cat
Section: cat
Page Number: 2526
Line Number: 81474
Interp Status: ---
Final Accepted Text:
======================================================================
Date Submitted: 2014-09-11 14:55 UTC
Last Modified: 2014-09-11 16:54 UTC
======================================================================
Summary: allow implementations to fail on 'cat a >> a'
======================================================================

----------------------------------------------------------------------
(0002379) shware_systems (reporter) - 2014-09-11 16:54
http://austingroupbugs.net/view.php?id=876#c2379
----------------------------------------------------------------------
Would it be better to make explicit, for those file types where the size is
known when the operand is encountered, that cat shall only copy those size
bytes in number, regardless of target? This would have

cat a >> a

only doubling in size, not entering an infinite loop that exhausts the
disk. I believe this matches better the intent of the utility; copy this
chunk of data, as it is now, to standard output.

Issue History
Date Modified Username Field Change
======================================================================
2014-09-11 14:55 eblake New Issue
2014-09-11 14:55 eblake Name => Eric Blake
2014-09-11 14:55 eblake Organization => Red Hat
2014-09-11 14:55 eblake User Reference => eblake.cat
2014-09-11 14:55 eblake Section => cat
2014-09-11 14:55 eblake Page Number => 2526
2014-09-11 14:55 eblake Line Number => 81474
2014-09-11 14:55 eblake Interp Status => ---
2014-09-11 16:23 eblake Note Added: 0002377
2014-09-11 16:27 eblake Note Added: 0002378
2014-09-11 16:54 shware_systems Note Added: 0002379
======================================================================
Austin Group Bug Tracker
2014-09-12 06:31:05 UTC
Permalink
A NOTE has been added to this issue.
======================================================================
http://austingroupbugs.net/view.php?id=876
======================================================================
Reported By: eblake
Assigned To:
======================================================================
Project: 1003.1(2013)/Issue7+TC1
Issue ID: 876
Category: Shell and Utilities
Type: Omission
Severity: Objection
Priority: normal
Status: New
Name: Eric Blake
Organization: Red Hat
User Reference: eblake.cat
Section: cat
Page Number: 2526
Line Number: 81474
Interp Status: ---
Final Accepted Text:
======================================================================
Date Submitted: 2014-09-11 14:55 UTC
Last Modified: 2014-09-11 16:23 UTC
======================================================================
Summary: allow implementations to fail on 'cat a >> a'
======================================================================

----------------------------------------------------------------------
(0002377) eblake (manager) - 2014-09-11 16:23
http://austingroupbugs.net/view.php?id=876#c2377
----------------------------------------------------------------------
Paul Eggert pointed out to me that the example at line 81508 may also need
updating:

Because of the shell language mechanism used to perform output redirection,
a command such as this:
cat doc doc.end > doc
causes the original data in doc to be lost.

On my test system, data was indeed lost
$ echo 1 > a
$ echo 2 > b
$ cat a b > a
cat: a: input file is output file
$ cat a
2

but it also demonstrates that cat merely skipped the processing of 'a',
rather than failing up front. So it may be better to document that an
input file is skipped if it is the same as the output (causing an overall
error), rather than my original proposed wording tied to the output file.

Issue History
Date Modified Username Field Change
======================================================================
2014-09-11 14:55 eblake New Issue
2014-09-11 14:55 eblake Name => Eric Blake
2014-09-11 14:55 eblake Organization => Red Hat
2014-09-11 14:55 eblake User Reference => eblake.cat
2014-09-11 14:55 eblake Section => cat
2014-09-11 14:55 eblake Page Number => 2526
2014-09-11 14:55 eblake Line Number => 81474
2014-09-11 14:55 eblake Interp Status => ---
2014-09-11 16:23 eblake Note Added: 0002377
======================================================================
Austin Group Bug Tracker
2014-09-12 06:30:55 UTC
Permalink
A NOTE has been added to this issue.
======================================================================
http://austingroupbugs.net/view.php?id=876
======================================================================
Reported By: eblake
Assigned To:
======================================================================
Project: 1003.1(2013)/Issue7+TC1
Issue ID: 876
Category: Shell and Utilities
Type: Omission
Severity: Objection
Priority: normal
Status: New
Name: Eric Blake
Organization: Red Hat
User Reference: eblake.cat
Section: cat
Page Number: 2526
Line Number: 81474
Interp Status: ---
Final Accepted Text:
======================================================================
Date Submitted: 2014-09-11 14:55 UTC
Last Modified: 2014-09-11 17:33 UTC
======================================================================
Summary: allow implementations to fail on 'cat a >> a'
======================================================================

----------------------------------------------------------------------
(0002381) Don Cragun (manager) - 2014-09-11 17:33
http://austingroupbugs.net/view.php?id=876#c2381
----------------------------------------------------------------------
Concerning http://austingroupbugs.net/view.php?id=876#c2377: The command: cat a
b > a
hoes not indicate that cat skipped the contents of a; the contents of a
were destroyed by the shell when it performed the requested redirection
before cat entered main().

Issue History
Date Modified Username Field Change
======================================================================
2014-09-11 14:55 eblake New Issue
2014-09-11 14:55 eblake Name => Eric Blake
2014-09-11 14:55 eblake Organization => Red Hat
2014-09-11 14:55 eblake User Reference => eblake.cat
2014-09-11 14:55 eblake Section => cat
2014-09-11 14:55 eblake Page Number => 2526
2014-09-11 14:55 eblake Line Number => 81474
2014-09-11 14:55 eblake Interp Status => ---
2014-09-11 16:23 eblake Note Added: 0002377
2014-09-11 16:27 eblake Note Added: 0002378
2014-09-11 16:54 shware_systems Note Added: 0002379
2014-09-11 17:02 eblake Note Added: 0002380
2014-09-11 17:33 Don Cragun Note Added: 0002381
======================================================================
Austin Group Bug Tracker
2014-09-12 06:31:05 UTC
Permalink
The following issue has been SUBMITTED.
======================================================================
http://austingroupbugs.net/view.php?id=876
======================================================================
Reported By: eblake
Assigned To:
======================================================================
Project: 1003.1(2013)/Issue7+TC1
Issue ID: 876
Category: Shell and Utilities
Type: Omission
Severity: Objection
Priority: normal
Status: New
Name: Eric Blake
Organization: Red Hat
User Reference: eblake.cat
Section: cat
Page Number: 2526
Line Number: 81474
Interp Status: ---
Final Accepted Text:
======================================================================
Date Submitted: 2014-09-11 14:55 UTC
Last Modified: 2014-09-11 14:55 UTC
======================================================================
Summary: allow implementations to fail on 'cat a >> a'
Description:
Several existing implementations of cat explicitly refuse to output to the
same file descriptor as any of its inputs, to avoid filling up the disk if
the file is non-empty:

Solaris:
$ cd /tmp/
$ touch a
$ /usr/bin/cat a >> a
cat: input/output files 'a' identical

GNU:
$ cd /tmp/
$ touch a
$ cat a >> a
cat: a: input file is output file

This behavior doesn't seem to be permitted by the standard, although it is
useful. The proposal here only fixes cat, although the group may decide to
make the allowance for same input/output rejection have wider scope.
Desired Action:
At line 81474 [XCU cat STDOUT], add a sentence:
If the standard output is a regular file, and is the same file as any of
the input file operands, the implementation may treat this as an error
without writing anything to the output file.
======================================================================

Issue History
Date Modified Username Field Change
======================================================================
2014-09-11 14:55 eblake New Issue
2014-09-11 14:55 eblake Name => Eric Blake
2014-09-11 14:55 eblake Organization => Red Hat
2014-09-11 14:55 eblake User Reference => eblake.cat
2014-09-11 14:55 eblake Section => cat
2014-09-11 14:55 eblake Page Number => 2526
2014-09-11 14:55 eblake Line Number => 81474
2014-09-11 14:55 eblake Interp Status => ---
======================================================================
Austin Group Bug Tracker
2014-09-12 06:31:05 UTC
Permalink
A NOTE has been added to this issue.
======================================================================
http://austingroupbugs.net/view.php?id=876
======================================================================
Reported By: eblake
Assigned To:
======================================================================
Project: 1003.1(2013)/Issue7+TC1
Issue ID: 876
Category: Shell and Utilities
Type: Omission
Severity: Objection
Priority: normal
Status: New
Name: Eric Blake
Organization: Red Hat
User Reference: eblake.cat
Section: cat
Page Number: 2526
Line Number: 81474
Interp Status: ---
Final Accepted Text:
======================================================================
Date Submitted: 2014-09-11 14:55 UTC
Last Modified: 2014-09-11 16:27 UTC
======================================================================
Summary: allow implementations to fail on 'cat a >> a'
======================================================================

----------------------------------------------------------------------
(0002378) eblake (manager) - 2014-09-11 16:27
http://austingroupbugs.net/view.php?id=876#c2378
----------------------------------------------------------------------
Arguably, using the fact that cat'ting a non-empty regular file to itself
will eventually fail due to the disk being full, one can argue that POSIX
already allows implementations to fail (and doesn't forbid from failing
early, rather than first exhausting the disk). After all, we justified the
reason that 'rm -rf /' is allowed to fail early rather than late based on
the fact that it will eventually fail when rm is itself removed, and
failing earlier is nicer if we can prove eventual failure would have
happened. But it then raises the issue of whether cat'ting an empty file
to itself is allowed to fail (since if permitted, it would not fill the
disk, therefore, we cannot prove that it would fail late, so it is harder
to justify it failing early).

Issue History
Date Modified Username Field Change
======================================================================
2014-09-11 14:55 eblake New Issue
2014-09-11 14:55 eblake Name => Eric Blake
2014-09-11 14:55 eblake Organization => Red Hat
2014-09-11 14:55 eblake User Reference => eblake.cat
2014-09-11 14:55 eblake Section => cat
2014-09-11 14:55 eblake Page Number => 2526
2014-09-11 14:55 eblake Line Number => 81474
2014-09-11 14:55 eblake Interp Status => ---
2014-09-11 16:23 eblake Note Added: 0002377
2014-09-11 16:27 eblake Note Added: 0002378
======================================================================
Austin Group Bug Tracker
2014-09-12 09:40:41 UTC
Permalink
A NOTE has been added to this issue.
======================================================================
http://austingroupbugs.net/view.php?id=876
======================================================================
Reported By: eblake
Assigned To:
======================================================================
Project: 1003.1(2013)/Issue7+TC1
Issue ID: 876
Category: Shell and Utilities
Type: Omission
Severity: Objection
Priority: normal
Status: New
Name: Eric Blake
Organization: Red Hat
User Reference: eblake.cat
Section: cat
Page Number: 2526
Line Number: 81474
Interp Status: ---
Final Accepted Text:
======================================================================
Date Submitted: 2014-09-11 14:55 UTC
Last Modified: 2014-09-12 09:40 UTC
======================================================================
Summary: allow implementations to fail on 'cat a >> a'
======================================================================

----------------------------------------------------------------------
(0002384) geoffclare (manager) - 2014-09-12 09:40
http://austingroupbugs.net/view.php?id=876#c2384
----------------------------------------------------------------------
I checked a bunch of other utilities on Solaris, HP-UX and Linux and the
only other one that produced an error was (GNU) grep on Linux. So we
should definitely make this change for grep as well, but I agree we should
consider allowing it for some other utilities.

The additional utilities I checked were: awk grep cut dd fold head m4 more
nl paste od pr sed tail uniq. The file I used was not empty, in case that
would make a difference.

Issue History
Date Modified Username Field Change
======================================================================
2014-09-11 14:55 eblake New Issue
2014-09-11 14:55 eblake Name => Eric Blake
2014-09-11 14:55 eblake Organization => Red Hat
2014-09-11 14:55 eblake User Reference => eblake.cat
2014-09-11 14:55 eblake Section => cat
2014-09-11 14:55 eblake Page Number => 2526
2014-09-11 14:55 eblake Line Number => 81474
2014-09-11 14:55 eblake Interp Status => ---
2014-09-11 16:23 eblake Note Added: 0002377
2014-09-11 16:27 eblake Note Added: 0002378
2014-09-11 16:54 shware_systems Note Added: 0002379
2014-09-11 17:02 eblake Note Added: 0002380
2014-09-11 17:33 Don Cragun Note Added: 0002381
2014-09-11 17:34 Don Cragun Note Edited: 0002381
2014-09-11 17:42 eblake Note Added: 0002382
2014-09-12 09:40 geoffclare Note Added: 0002384
======================================================================
Loading...