NetBSD-Bugs archive

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

Re: bin/57252: wc



The following reply was made to PR bin/57252; it has been noted by GNATS.

From: Robert Elz <kre%munnari.OZ.AU@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: marc%fege.net@localhost, rvp%SDF.ORG@localhost, netbsd-bugs%netbsd.org@localhost
Subject: Re: bin/57252: wc
Date: Thu, 02 Mar 2023 19:40:18 +0700

     Date:        Thu,  2 Mar 2023 08:05:00 +0000 (UTC)
     From:        marc%fege.net@localhost
     Message-ID:  <20230302080500.669DD1A923C%mollari.NetBSD.org@localhost>
 
   | the "wc" command does not behave as POSIX demands: POSIX requires
   | the outputted figures to be tabbed by the actual horizontal tab character.
 
 Nonsense.   It requires nothing of the kind.   If you believe otherwise
 please quote the text which says so.
 
 
 rvp%SDF.ORG@localhost said:
   |  And, SUSv4 2018 actually recommends a single space instead of tabs:
 
 No, it doesn't do that either.
 
 This:
   |       STDOUT
   |          By default, the standard output shall contain an entry for each
   |          input file of the form:
   |             "%d %d %d %s\n", <newlines>, <words>, <bytes>, <file>
 
 needs to be read in combination with XCU 1.4 (Utility Description Details)
 where (in the section on STDOUT) it says:
 
 	Record formats are described in a notation similar to that used
 	by the C-language function, printf( ). See XBD Chapter 5 (on page ...)
 	for a description of this notation.
 
 I omitted the page number from here, as that varies from version to
 version, the one I cut this from is not easily available (and page numbers
 are not applicable to the web version most people access).
 
 XBD 5 (File Format Notation) describes a (modified) printf specification
 which is used throughout the standard, in that:
 
 	The following characters have the following special meaning
         in the format string:
 
 	' ' (An empty character position.) Represents one or more <blank>
 	characters.
 
 There's also a delta char (which I don't know how to type...) which
 is used when a literal space is required (one space for one delta in the
 format string).   That is rarely used.
 
 <blank> is space or tab.   So when the format string in the STDOUT section
 of a utility description says "%d %d" what it means is two decimal integers,
 separated by (at least one) white space characters - any number of spaces or
 tabs, in any order, is OK.
 
 rvp%SDF.ORG@localhost said:
   |  Well, those extra spaces are annoying, but, you can get rid of them
   |  pretty easily like this:
   |    $ x=$(x=$(wc -l < /etc/motd); echo $x)
 
 It is a lot easier than that, without requiring 2 subshells:
 
 	x=$(( $( wc -l < /etc/motd ) ))
 
 kre
 


Home | Main Index | Thread Index | Old Index