Thread (4 messages) flat view 4 messages, 4 authors, 2016-06-15

Re: [RFC] Cleaning up die() error messages

From: Daniel Barkalow <hidden>
Date: 2016-06-15 22:42:08

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*
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help