coreutils
[Top][All Lists]
Advanced

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

Re: du: POSIX mandating a single space instead of tab?


From: Eric Blake
Subject: Re: du: POSIX mandating a single space instead of tab?
Date: Tue, 28 Apr 2015 08:42:07 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0

On 04/28/2015 03:59 AM, Pádraig Brady wrote:

>>>     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>
>>>
>>> Instead, GNU du uses "%d\t%s\n", i.e., a tab character as delimiter,
>>> even if POSIXLY_CORRECT is set.
>>>
>>> Do I read POSIX right?
>>
>> No, the space stands for any (positive) amount of white space.
>>
>> http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap05.html#tag_05
>>
>> Andreas.
>>
> 
> Thanks for pointing that out Andreas.
> So a ' ' in a format implies any amount of blank chars.

Correct.

> So we could separate the du columns with spaces rather than tab,

Yes, I'd prefer that we did that.  It is much easier to guarantee
alignment when using spaces and completely avoiding whatever tab stops
people have set up.

> though that would almost definitely introduce a compatibility issue,
> and would be inconsistent with Solaris and FreeBSD at least.

POSIX is already clear that anyone parsing for literal tabs is broken
when trying to parse du output.  The only safe way to parse du output is
to break on all whitespace (the way awk already does).  I'm 70-30 in
favor of changing to spaces.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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