View Issue Details

IDProjectCategoryView StatusLast Update
0001826Issue 8 draftsShell and Utilitiespublic2024-05-20 15:29
Reporterlanodan Assigned To 
PrioritynormalSeverityCommentTypeEnhancement Request
Status ClosedResolutionRejected 
Product VersionDraft 4.1 
NameHaelwenn Monnier
Organization
User Reference
Sectiondu
Page Number2808
Line Number93064-93067
Final Accepted Text
Summary0001826: du: space used between <size> and <pathname>, while common implementations use tab
DescriptionOnes where a tab is used as separator, version and permalinks as observance point:
- BSD 4.1 (literal) https://github.com/dspinellis/unix-history-repo/blob/6e5f0f7526b38c1ab3620133892ecf1fe15a1d2b/usr/src/usr.bin/du/du.c#L158
- NetBSD http://cvsweb.netbsd.org/bsdweb.cgi/src/usr.bin/du/du.c?rev=1.36&content-type=text/x-cvsweb-markup&only_with_tag=MAIN
- OpenBSD https://cvsweb.openbsd.org/src/usr.bin/du/du.c?rev=1.33&content-type=text/x-cvsweb-markup
- FreeBSD https://cgit.freebsd.org/src/tree/usr.bin/du/du.c?id=0b8224d1cc9dc6c9778ba04a75b2c8d47e5d7481#n316
- MacOS https://github.com/apple-oss-distributions/file_cmds/blob/file_cmds-430.100.5/du/du.c#L402
- GNU coreutils 9.4, even with POSIXLY_CORRECT=1 and POSIX_ME_HARDER=1
- BusyBox 1.36.1
- ToyBox https://github.com/landley/toybox/blob/9303bd8ae667ef6385f070aa4937ff8746a2ff59/toys/posix/du.c#L75

illumos being the only one I could find where when compiled for /usr/xpg4/bin/du rather than /usr/bin/du, a space is used: https://github.com/illumos/illumos-gate/blob/1979231e1e29c981e5d1e6cee60f2db46d052b00/usr/src/cmd/du/du.c#L72-L81

A hunch I have is the literal tab degrading into a space on POSIX side of things.
Desired ActionGiven how widespread tab separation is: Either changing the specified format of du(1), line 93067 on Draft 4.1, from "%d %s\n" to "%d\t%s\n" or clarifying that either space or tab can be used as separator.
TagsNo tags attached.

Activities

philip-guenther

2024-04-07 02:07

reporter   bugnote:0006742

The standard doesn't specify a space between <size> and <pathname>. It says:
----
STDOUT
    The output from du shall consist of the amount of space allocated to a file and the name of the
    file, in the following format:
    "%d %s\n", <size>, <pathname>
----

But the STDOUT section is _defined_ by XCU 1.4 where it says:
----
    The STDOUT section completely describes the standard output of the utility. This
    section is frequently merely a reference to the following section, OUTPUT FILES,
    because many utilities treat standard output and output files in the same manner.
...
    Record formats are described in a notation similar to that used by the C-language
    function, printf(). See XBD Chapter 5 (on page 121) for a description of this notation.
----

and when you follow that last reference you find:
----
    The following characters have the following special meaning in the format string:
    ’ ’ (An empty character position.) Represents one or more <blank> characters.
    ∆ Represents exactly one <space> character.
----

So the du specification specifies one or more <blank> (space and tab) characters between the <size> and <pathname>

Issue History

Date Modified Username Field Change
2024-04-07 01:48 lanodan New Issue
2024-04-07 01:48 lanodan Name => Haelwenn Monnier
2024-04-07 01:48 lanodan Section => du
2024-04-07 01:48 lanodan Page Number => 2808
2024-04-07 01:48 lanodan Line Number => 93064-93067
2024-04-07 02:07 philip-guenther Note Added: 0006742
2024-05-20 15:29 Don Cragun Status New => Closed
2024-05-20 15:29 Don Cragun Resolution Open => Rejected