From 012222e38cd0b48a3dabd10c9a3cf6b2c4c5befc Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Fri, 26 Sep 2014 22:16:26 +0800 Subject: [MAN] Change characters for printf precision to bytes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Sun, Mar 09, 2014 at 11:11:43AM +0000, Jeroen van Dijke wrote: > > There seems to be a bug in the dash man page, at least in 0.5.7. It reads: > > Precision: > An optional period, `.', followed by an optional digit string giving a precision which specifies the number of digits to appear after the decimal point, for e and f formats, or the maximum number of *characters* to be printed from a string (b and s for- > mats); if the digit string is missing, the precision is treated as zero; > > dash behaves cuts to the number of bytes > > $ length=10; printf "%.${length}s\n" "eeeeeeeeeeeeeeeeeeeeeeeee" > eeeeeeeeee > $ length=10; printf "%.${length}s\n" "ëëëëëëëëëëëëëëëëëëëëëëëëë” > ëëëëë > > > The POSIX specification (2008) says: > > precision Gives the minimum number of digits to appear for the d, o, i, u, x, or X conversion specifiers (the field is padded with leading zeros), the number of digits to appear after the radix character for the e and f conversion specifiers, the maximum number of significant digits for the g conversion specifier; or the maximum number of *bytes* to be written from a string in the s conversion specifier. The precision shall take the form of a ( '.' ) followed by a decimal digit string; a null digit string is treated as zero. > > So it seems to me that “characters” should be changed to “bytes”. Indeed and this patch makes that change. Signed-off-by: Herbert Xu --- ChangeLog | 1 + 1 file changed, 1 insertion(+) (limited to 'ChangeLog') diff --git a/ChangeLog b/ChangeLog index 7b67c0c..6f27fd7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ * Small optimisation of command -pv change. * Set command -p path to /usr/sbin:/usr/bin:/sbin:/bin. + * Change "characters" for printf precision to "bytes". 2014-09-26 Harald van Dijk -- cgit 1.4.1