From owner-freebsd-current Fri Apr 12 01:16:20 1996 Return-Path: owner-current Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id BAA10147 for current-outgoing; Fri, 12 Apr 1996 01:16:20 -0700 (PDT) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id BAA10142 for ; Fri, 12 Apr 1996 01:16:12 -0700 (PDT) Received: (from bde@localhost) by godzilla.zeta.org.au (8.6.12/8.6.9) id SAA04035; Fri, 12 Apr 1996 18:12:52 +1000 Date: Fri, 12 Apr 1996 18:12:52 +1000 From: Bruce Evans Message-Id: <199604120812.SAA04035@godzilla.zeta.org.au> To: current@FreeBSD.ORG, erich@lodgenet.com Subject: Re: /bin/sh's printf Sender: owner-current@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >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