From: Daniel Barkalow <barkalow@iabervon.org>
To: Elfyn McBratney <beu@gentoo.org>
Cc: git mailing list <git@vger.kernel.org>
Subject: Re: [RFC] Cleaning up die() error messages
Date: Mon, 10 Oct 2005 16:14:31 -0400 (EDT) [thread overview]
Message-ID: <Pine.LNX.4.63.0510101603520.23242@iabervon.org> (raw)
In-Reply-To: <20051010105008.GB30202@gentoo.org>
On Mon, 10 Oct 2005, Elfyn McBratney wrote:
> [C sources]
> static char *prog;
> ..
> static inline void set_prog_name (char *argv0)
> {
> prog = strrchr(argv0, '/');
> if (prog)
> prog++;
> else
> prog = argv0;
> }
> ..
> int main (int argc, char **argv)
> {
> set_prog_name(argv[0]);
> ..
> if (!do_bar())
> die("%s: do_bar() failed", prog);
> ..
> }
Just put set_prog_name() next to die(), and have die() write "prog: " at
the beginning if set_prog_name() got called. Assuming it's useful at all
to show the name of the program, it's not going to be less useful if the
error is actually found in a library function called by the program.
-Daniel
*This .sig left intentionally blank*
next prev parent reply other threads:[~2005-10-10 20:09 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-10 10:50 [RFC] Cleaning up die() error messages Elfyn McBratney
2005-10-10 19:04 ` Junio C Hamano
2005-10-11 19:48 ` Matthias Urlichs
2005-10-11 20:50 ` H. Peter Anvin
2005-10-12 1:20 ` Matthias Urlichs
2005-10-12 3:18 ` H. Peter Anvin
2005-10-12 4:25 ` Junio C Hamano
2005-10-12 4:40 ` H. Peter Anvin
2005-10-12 5:02 ` Junio C Hamano
2005-10-12 6:04 ` Matthias Urlichs
2005-10-10 20:14 ` Daniel Barkalow [this message]
2005-10-11 15:02 ` Alex Riesen
2005-10-11 16:11 ` H. Peter Anvin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.63.0510101603520.23242@iabervon.org \
--to=barkalow@iabervon.org \
--cc=beu@gentoo.org \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).