home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / unix / question / 14757 < prev    next >
Encoding:
Text File  |  1992-12-17  |  2.2 KB  |  60 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!casbah.acns.nwu.edu!navarra
  3. From: navarra@casbah.acns.nwu.edu (John Navarra)
  4. Subject: Re: cat a > a , getting it straight
  5. Message-ID: <1992Dec17.074018.3226@news.acns.nwu.edu>
  6. Sender: usenet@news.acns.nwu.edu (Usenet on news.acns)
  7. Nntp-Posting-Host: unseen1.acns.nwu.edu
  8. Organization: Northwestern University, Evanston Illinois.
  9. References: <1992Dec17.020805.28043@news.acns.nwu.edu> <1gp7lsINNlok@early-bird.think.com>
  10. Date: Thu, 17 Dec 1992 07:40:18 GMT
  11. Lines: 47
  12.  
  13. In article <1gp7lsINNlok@early-bird.think.com> barmar@think.com (Barry Margolin) writes:
  14. >In article <1992Dec17.020805.28043@news.acns.nwu.edu> navarra@casbah.acns.nwu.edu (John Navarra) writes:
  15. >>Why does appending a to a with cat not work but wc a >> a does produce
  16. >>the output from wc that is expected?  
  17. >
  18. >Because cat checks whether the input and output are the same file.  When
  19. >this is so, it prints the warning message and exits.  Wc (and most other
  20. >programs) doesn't check, so the expected thing happens.
  21.  
  22. Ok, this, I expected. After discussing this with Leif Jensen though, I found
  23. some more interesting stuff which we can't explain. Check this out:
  24.  
  25. [casbah:67] ~/tmp -> uname -a
  26. unOS casbah.ac 4.1.2_DB 14 sun4m
  27. [casbah:68] ~/tmp -> cat a | cat > a
  28. [casbah:69] ~/tmp -> cat a
  29. file a
  30. [casbah:70] ~/tmp -> cat a | cat > a
  31. [casbah:71] ~/tmp -> cat a
  32.  
  33. [riemann:59] ~/tmp -> unset noclobber
  34. [riemann:60] ~/tmp -> uname -a
  35. SunOS riemann 4.1.1-IP 2 sun4c
  36. [riemann:61] ~/tmp -> cat a 
  37. file a
  38. [riemann:62] ~/tmp -> cat a | cat > a
  39. [riemann:63] ~/tmp -> cat a
  40. file a
  41.  
  42. But, this output is not predictable. Sometimes, a was clobbered several
  43. times in a row. Sometimes, a was preserved several times in a row. Once,
  44. I even got this:
  45.  
  46. [casbah:58] ~/tmp -> cat a | cat > a
  47. cat: write error: Bad address
  48.  
  49. Somebody is not doing their job right. I couldn't reproduce this on non-Sun
  50. machines though.
  51.  
  52. -tms
  53.  
  54.  
  55. -- 
  56. You can get further with a kind word | You can get further with a kind word
  57. and a gun than a kind word alone.    | and a phaser than a kind word and a gun.
  58.           --al capone                |           -- John Navarra
  59. =======From the Lab of the MaD ScIenTIst....navarra@casbah.acns.nwu.edu========
  60.