home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / unix / wizards / 4772 < prev    next >
Encoding:
Internet Message Format  |  1992-11-17  |  1.6 KB

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