Date: Fri, 7 Jan 2000 11:30:57 -0800 (PST) From: Archie Cobbs <archie@whistle.com> To: bde@zeta.org.au (Bruce Evans) Cc: sheldonh@uunet.co.za, freebsd-bugs@FreeBSD.ORG Subject: Re: bin/15929: printf(1) truncates if it sees 000 Message-ID: <200001071930.LAA57370@bubba.whistle.com> In-Reply-To: <Pine.BSF.4.10.10001071850410.5889-100000@alphplex.bde.org> from Bruce Evans at "Jan 7, 2000 07:00:59 pm"
next in thread | previous in thread | raw e-mail | index | archive | help
Bruce Evans writes: > > > > $ printf 'a\000truncated\n' > > > > > > > > This outputs "a" instead of "a<NUL>truncated" > > > > > > What would you expect to happen, given that printf(3) exhibits the same > > > behaviour? > > > > No, I'm not at all surprised. > > > > But that's not the point, of course. Either the bug should be fixed > > or else at least declared 'normal' and so documented in the man page. > > printf(1) does seem to be incompatible with printf(3) here. From a POSIX > draft: > > (3) In addition to the escape sequences shown in Table 2-15 (see > 2.12), \ddd, where ddd is a one-, two-, or three-digit octal > number, shall be written as a byte with the numeric value > specified by the octal number. > converted string shall be written. > > There seems to be no special case for the escape sequence \000. I think > this is a bug in the POSIX draft. In C, printf(3) would never see the > escape sequence \000; it would see a hard \0. You would have to use %c > format to print a hard \0. In fact, there seems to be no way to print a NUL character using printf(1), which is why I got stuck in the first place. If you try ``printf "%c" 0'' then you get '0' instead of NUL. If you try ``printf "\000"'' then you get the empty string. -Archie ___________________________________________________________________________ Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200001071930.LAA57370>