Austin Group Defect Tracker

Aardvark Mark IV


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0000407 [1003.1(2008)/Issue 7] Shell and Utilities Objection Enhancement Request 2011-04-14 23:36 2024-06-11 08:53
Reporter eblake View Status public  
Assigned To ajosey
Priority normal Resolution Accepted As Marked  
Status Closed  
Name Eric Blake
Organization Red Hat
User Reference ebb.head
Section head
Page Number 2791
Line Number 91030
Interp Status ---
Final Accepted Text Note: 0000752
Summary 0000407: add head -c
Description The rationale for head states (XCU line 91101):

There is no −c option (as there is in tail) because it is not historical
practice and because other utilities in this volume of POSIX.1-2008
provide similar functionality.

but does not name what those other utilities might be. The only one I
can think of is dd; however, while dd can indeed truncate input after a
particular number of bytes, it requires the use of ibs=1 which results
in rather inefficient operation. This is tracked separately as
0000406

Both GNU and BSD implementations of head support -c with much more
efficient operation than dd, and the ability to truncate input after
an arbitrary number of bytes seems useful enough to standardize for
Issue 8.
Desired Action At line 91030 [XCU head SYNOPSIS], change:

head [−n number] [file...]

to:

head [-c number|−n number] [file...]

At line 91034 [head DESCRIPTION], change:

Copying shall end at the point in each input file indicated by the −n
number option. The option-argument number shall be counted in units of
lines.

to:

Copying shall end at the point in the file indicated by the −c number or
−n number options. The option-argument number shall be counted in units
of lines or bytes, according to the options −n and −c. Both line and byte
counts start from 1.

At line 91039 [head OPTIONS], change:

−n number The first number lines of each input file shall be copied to
standard output. The application shall ensure that the number
option-argument is a positive decimal integer.

When a file contains less than number lines, it shall be copied to
standard output in its entirety.

to:

−c number The first number bytes of each input file shall be copied to
standard output. The application shall ensure that the number
option-argument is a positive decimal integer.

−n number This option shall be equivalent to −c number, except the ending
location in the file shall be measured in lines instead of bytes.

When a file contains less than number bytes or lines, it shall be copied
to standard output in its entirety.

At line 91054 [head INPUT FILES], change:

Input files shall be text files, but the line length is not restricted to
{LINE_MAX} bytes.

to:

If the −c option is specified, the input files can contain arbitrary data; otherwise, the input files shall be text files, but the line length is
not restricted to {LINE_MAX} bytes.

At line 91101 [head RATIONALE], change:

There is no −c option (as there is in tail) because it is not historical
practice and because other utilities in this volume of POSIX.1-2008
provide similar functionality.

to:

Head and tail have not historically been symmetric. For example, this
standard only requires tail to support at most one file operand, while
head must operate on multiple files. Conversely, this standard requires
tail to be able to start at a position relative to the start of a file,
but head need not support stopping at a position relative to the end of
the file. Implementations may make the choose to make head and tail
symmetric as an extension, but applications should not rely on this.

Older implementations of head did not support -c number, but emulating
this via dd ibs=1 count=number is less efficient.
Tags issue8
Attached Files

- Relationships
related to 0000406Closedajosey add dd iflags=fullblock, for better pipe interaction 

-  Notes
(0000743)
geoffclare (manager)
2011-04-16 10:49

I would suggest a slight change to the end of the proposed rationale
addition, to acknowledge the alternative solution of two piped dd
processes (in cases where the number of bytes is a convenient multiple):

Older implementations of head did not support -c number, but emulating
this via dd ibs=1 count=number is much less efficient and emulating
via dd obs=pipe_buf | dd ibs=size count=number_of_blocks is cumbersome,
somewhat less efficient, and can only be used if the number of bytes
to be copied is a multiple of a suitable block size less than or equal
to PIPE_BUF.
(0000752)
msbrown (manager)
2011-04-21 16:15

Take Desired Action as modified by Note: 0000743

- Issue History
Date Modified Username Field Change
2011-04-14 23:36 eblake New Issue
2011-04-14 23:36 eblake Status New => Under Review
2011-04-14 23:36 eblake Assigned To => ajosey
2011-04-14 23:36 eblake Name => Eric Blake
2011-04-14 23:36 eblake Organization => Red Hat
2011-04-14 23:36 eblake User Reference => ebb.head
2011-04-14 23:36 eblake Section => head
2011-04-14 23:36 eblake Page Number => 2791
2011-04-14 23:36 eblake Line Number => 91030
2011-04-14 23:36 eblake Interp Status => ---
2011-04-16 10:49 geoffclare Note Added: 0000743
2011-04-21 16:13 msbrown Tag Attached: issue8
2011-04-21 16:15 msbrown Note Added: 0000752
2011-04-21 16:15 msbrown Status Under Review => Resolved
2011-04-21 16:15 msbrown Resolution Open => Accepted As Marked
2011-04-21 16:15 msbrown Final Accepted Text => Note: 0000752
2011-04-28 16:52 eblake Relationship added related to 0000406
2020-03-03 14:43 geoffclare Status Resolved => Applied
2024-06-11 08:53 agadmin Status Applied => Closed


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker