home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.wizards:4772 comp.unix.shell:4767 comp.unix.misc:4237
- Newsgroups: comp.unix.wizards,comp.unix.shell,comp.unix.misc
- Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!rpi!utcsri!newsflash.concordia.ca!sifon!thunder.mcrcim.mcgill.edu!mouse
- From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
- Subject: Re: The Problem with UNIX
- Message-ID: <1992Nov18.110609.9149@thunder.mcrcim.mcgill.edu>
- Organization: McGill Research Centre for Intelligent Machines
- References: <1992Nov11.194557.16258@yarc.uucp> <1992Nov12.204710.5808@reed.edu> <1992Nov16.234721.3224@nic.csu.net>
- Date: Wed, 18 Nov 92 11:06:09 GMT
- Lines: 28
-
- In article <1992Nov16.234721.3224@nic.csu.net>, oleg@gd. (Oleg Kibirev) writes:
-
- > Seriously, I would really appreciate a call like eprintf that accepts
- > the same arguments as printf but also has staff like %n for program
- > name, %m for message, %p for callers PID etc.
-
- All of these are available:
-
- %s argv[0],
- %s ((errno>0)&&(errno<sys_nerr))?sys_errlist[errno]:"Unknown error"
- %d getpid()
-
- Given the ugliness (and incompleteness - it should include the error
- number in the "unknown error" clause) of the second one, I hacked on
- printf to add a %m spec, which takes an errno and generates the
- corresponding message. Makes printing error messages ever so much
- easier to write...
-
- fprintf(stderr,"%s: can't open %s: %m\n",argvec[0],fn,errno);
-
- Of course, this helps only when errno contains something useful. Far
- too many things don't do this - fopen, for example, does not have
- anything to do with errno as any part of its contract....
-
- der Mouse
-
- mouse@larry.mcrcim.mcgill.edu
-