home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / std_unix / mod.std.unix.v9 / text0037.txt < prev    next >
Encoding:
Internet Message Format  |  1987-06-30  |  2.1 KB

  1. From: guy%gorodish@Sun.COM (Guy Harris)
  2. Date: 29 Jan 87 07:12:50 GMT
  3. Reply-To: guy@sun.UUCP (Guy Harris)
  4. Organization: Sun Microsystems, Mountain View
  5.  
  6. >    While we're it, make "cmp" call the first character in a file 0.
  7. >At least on my 4.2BSD system, cmp says the first character in a file is 1.
  8.  
  9. "cmp" hasn't changed a lot, so all the other AT&T-derived "cmp"s do
  10. this.
  11.  
  12. >I would imagine most people only use cmp to test for equality of files, but
  13. >I had reason to use the output of "cmp -l" the other day in a shell script
  14. >and got burned my this.  Most likely, somebody needs to carefully go
  15. >through every command in the book and ferret out count from 0/1 problems.
  16.  
  17. If people actually use the output of "cmp" in shell scripts, you
  18. can't just "make 'cmp' call the first character in a file 0", since
  19. this may break shell scripts.  You do, however, have to document
  20. whether it calls that byte 0 or 1, and you also have to document
  21. precisely the format of its output, so you *can* use it in shell
  22. scripts.
  23.  
  24. >    Along those lines, what does it mean when some processor says
  25. >"error in line 0, file foo"?  On the one hand, it makes computer sense to
  26. >call the "first" line/character/block/whatever of a file 0.
  27.  
  28. For characters and blocks, maybe.  For lines, it may make computer
  29. sense, but not a lot of sense otherwise.  Text editors currently call
  30. the first line line 1, and even people exposed to C for prolonged
  31. periods of time do so as well (probably because their text editor
  32. does...).
  33.  
  34. >On the other hand, it is very convienent to reserve "error in line 0" to
  35. >mean "something went wrong before I even got a chance to start reading the
  36. >file."
  37.  
  38. Convenient for the programmer writing the code printing the error
  39. message, maybe, but that doesn't count.  What counts in this case is
  40. convenience to the *user*, and an error message that leaves the line
  41. number out entirely - and even the file name, if the error doesn't
  42. pertain to the file - is far more convenient there.
  43.  
  44. When some program says "error in line 0, file foo", it generally
  45. means the programmer who wrote that code was too lazy to get the
  46. error message right.
  47.  
  48. Volume-Number: Volume 9, Number 38
  49.  
  50.