Re: [PATCH v2 1/3] Introduce die_errno() that appends strerror(errno) to die()
- From
Jeff King <peff@peff.net>
- Date
- Jun 8, 2009, 12:36 UTC
- Message-ID
- <20090608123608.GG13775@coredump.intra.peff.net>
- In-Reply-To
- <7vzlck9e3j.fsf@alter.siamese.dyndns.org>
On Sun, Jun 07, 2009 at 09:57:04AM -0700, Junio C Hamano wrote:
Show 14 quoted lines
> > This breaks theoretical usage of custom format string in custom die > > routines: > > 1. A custom die routine might not support %s. > > 2. If the die routine adds a custom format specifier, vsnprintf > > will fail. > > I do not think that flies even as a theory. The "custom" 39a3f5ea talks > about is more about "Instead of sending it to stderr, let's pop up an info > window and give the message there" kind of customization. > > Existing die() that prints errno does so by giving strerror() to "%s", so > no matter how custom your die routine is, you must support '%s' for its > output to make sense to humans. If you "not support %s", then you will > ignore (or choke at) such strerror() result without this patch anyway.
More than that, you must support arbitrary printf format strings, because the die routine is passed whatever goes to die() (a quick grep revealed that we use at least %u and %c at various points). So it is an undocumented requirement that the die routine process its parameters as if it were from the printf family.
I think what Thomas posted is fine.
-Peff