Re: [hackers] [PATCH v3][sbase] cmp: Make output of error message POSIX compliant

From: Richard Ipsum <richardipsum_AT_fastmail.co.uk>
Date: Tue, 21 May 2019 19:16:26 +0100

On Tue, May 21, 2019 at 09:19:55AM +0200, Hiltjo Posthuma wrote:
> On Tue, May 21, 2019 at 05:37:27AM +0100, Richard Ipsum wrote:
> > On Mon, May 20, 2019 at 07:06:04PM -0700, Michael Forney wrote:
> > > On 2019-05-20, Laslo Hunhold <dev_AT_frign.de> wrote:
> > > > On Mon, 20 May 2019 09:36:32 +0100
> > > > Richard Ipsum <richardipsum_AT_fastmail.co.uk> wrote:
> > > >
> > > > Dear Richard,
> > > >
> > > >> - weprintf("cmp: EOF on %s\n",
> > > >> argv[(b[0] != EOF)]);
> > > >> + fprintf(stderr, "cmp: EOF on %s\n",
> > > >
> > > > maybe I am missing something, but weprintf() already does print to
> > > > stderr. What does this patch change?
> > >
> > > weprintf also adds a prefix "%s: ", argv0, so we end up with a double prefix
> > >
> > > cmp: cmp: EOF on ...
> > >
> > > I think Richard is using fprintf directly since POSIX specifies that
> > > the message should be exactly
> > >
> > > "cmp: EOF on %s%s\n", <name of shorter file>, <additional info>
> > >
> > > which might not be the case if cmp is called by its absolute path.
> > >
> >
> > Exactly
> >
> > Thanks,
> > Richard
> >
>
> Have you compared it to other implementations? I think it should output to stdout.

I thought so too, but the standard says it should be written to stderr.

cmp on OpenBSD prints "cmp: EOF on W" to stderr, cmp on Debian prints the same.

>
> I'd also prefer to use the exact line format because POSIX specifies it.
> I think many understand the difference between char and wchar anyway.

I assume the maintainer will decide one way or the other.

Thanks,
Richard
Received on Tue May 21 2019 - 20:16:26 CEST

This archive was generated by hypermail 2.3.0 : Tue May 21 2019 - 20:24:23 CEST