Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • 5
    Almost correct, excepr it's "small furry" (creatures from Alpha Centauri) not "furry little"! Commented Oct 24, 2018 at 16:38
  • 2
    @T.E.D.: It's entirely possible early versions of cp just opened the destination with O_CREAT | O_TRUNC and performed a read/write loop; sure, with modern cp there are so many knobs that it basically has to try to stat the destination beforehand, and could easily check for existence first (and does with cp -i/cp -n), but if the expectations were established from original, bare bones cp tools, changing that behavior would break existing scripts needlessly. It's not like modern shells with alias can't just make cp -i the default for interactive use after all. Commented Oct 24, 2018 at 19:59
  • @ShadowRanger - Hmmm. You're quite right that I really have no idea if it was easy or hard to do. Comment deleted. Commented Oct 24, 2018 at 20:04
  • 1
    @ShadowRanger Yeah, but then that's just pushing the hard lesson down the road until it's on a production system... Commented Oct 25, 2018 at 0:38
  • 4
    @sourcejedi: Fun! Doesn't change my basic theory (that it was easier to just unconditionally open with truncation, and creat happens to be equivalent to open+O_CREAT | O_TRUNC), but the lack of O_EXCL does explain why it wouldn't have been so easy to handle existing files; trying to do so would be inherently racy (you'd basically have to open/stat to check existence, then use creat, but on large shared systems, it's always possible by the time you got to creat, someone else made the file and now you've blown it away anyway). May as well just overwrite unconditionally. Commented Oct 25, 2018 at 12:58