tech-userlevel archive

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

Re: non-POSIX behavior from wc(1)



On Mon, Jan 18, 2016 at 01:20:13PM -0500, Greg Troxel wrote:
> 
> On NetBSD 6, one gets wc output with pleasing spaces
> 
> $ wc -l unison.log cmake.diff
>        1 unison.log
>       58 cmake.diff
>       59 total
> $ wc unison.log cmake.diff
>        1       7      45 unison.log
>       58     168    2461 cmake.diff
>       59     175    2506 total
> $
> 
> But POSIX says:
> 
>    "%d %d %d %s\n", <newlines>, <words>, <bytes>, <file>
> 
> which does not have extra spaces.  This only matters if you write code
> to parse the output based on the spec:

That is still correct behaviour, those printf-like specifications
are illustrative rather than literal.  Refer to the section File
Format Notation in the Base Specifications:

The following characters have the following special meaning in the
format string:

' '
    (An empty character position.) Represents one or more <blank>
    characters...

-- 
Andrew Smallshaw
andrews%sdf.lonestar.org@localhost


Home | Main Index | Thread Index | Old Index