Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Apr 1996 18:12:52 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        current@FreeBSD.ORG, erich@lodgenet.com
Subject:   Re: /bin/sh's printf
Message-ID:  <199604120812.SAA04035@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>I've stumbled across a little problem with sh's printf,
>could someone explain what's going on here:

>(ttyp0@jake)$ /bin/sh
>(ttyp0@jake)$ printf "%04d\n" 12
>  12
>(ttyp0@jake)$ /usr/bin/printf "%04d\n" 12
>0012

sh's printf is limited.  It interprets 04 as (0*10 * 10).

>It looks like they're compiled from the same sources even --??

No, sh uses its own limited formatting routine doformat().  I
think the sources are shared between csh(1) and printf(1), but
then I thought that they were shared with sh(1) before I looked
at them :-).  Perhaps everything should use vfprintf() and
fwopen().  There's little chance that everything would agree
about obscure flags or floating point otherwise.  sh doesn't
understand floating point formats at all...

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199604120812.SAA04035>