error(s1, s2) char *s1; char *s2; warning(s1, s2) char *s1; char *s2; extern char *progname; extern int errno; progname = argv[0];
If there is an environment variable CMDNAME with non-null value, its contents are printed first, followed by a colon. Following this, any non-null value of progname is printed, followed by a colon and a space. Following this, fprintf(3) is invoked with s1 as the format string and s2 as the argument. If the value of errno is within the normal range, a standard elaborating message is printed (see intro(2)).
CMDNAME should be set by shellfiles that expect subordinate programs to issue error message in the shellfile's name. Progname should be set by all programs; argv[0] is usually a suitable thing to set it to. Errno is set by system calls and various other routines, although its use is not universal; note that it is not reset by successful system calls following an unsuccessful one.