From: utzoo!decvax!cca!dan@Bbn-Unix@sri-unix
Newsgroups: net.unix-wizards
Title: Re: Identify program error messages, please!
Article-I.D.: sri-unix.2809
Posted: Sat Aug 21 00:50:07 1982
Received: Sun Aug 22 00:59:01 1982

From: Dan Franklin 
Date: 10 Aug 1982  9:52:14 EDT (Tuesday)
When I started working with UNIX I wrote a set of routines which act
a lot like printf, but make it easy to print the name of the
command and the system error. The basic one was 
	cmderr(errno_value, format_string, args...)
which printed out the value of the global variable "progname",
followed by a colon, followed by the format_string and args a la printf,
followed by the system error message corresponding to errno_value
(if it's not zero). If errno_value was -1 it looked at "errno" itself
and used that. A useful variant of this routine was "ecmderr", which did
all that and then exited. 

The problem with any routine which takes a fixed number of arguments
is that I always have more to say than it can accomodate. The typical
case is a failed open; I want to print the program name, an error message
containing the filename, and the system error message. Only printf-style
routines are flexible enough to handle this and similar cases.