• Björn@swg-empire.de
    link
    fedilink
    arrow-up
    0
    ·
    2 years ago

    Yeah. It could just as well have issued a file not found error when you try to touch a nonexistent file. And we would be none the wiser about what we’re missing in the world.

    • 4am@lemm.ee
      link
      fedilink
      arrow-up
      0
      ·
      2 years ago

      “Do one thing and do it very well” is the UNIX philosophy after all; if you’re 99% likely to just create that missing file after you get a file not found error, why should touch waste your time?

      • T. Hex@lemmy.dbzer0.com
        link
        fedilink
        arrow-up
        0
        ·
        2 years ago

        Because now touch does two things.

        Without touch, we could “just” use the shell to create files.

        : > foo.txt
        
        • deegeese@sopuli.xyz
          link
          fedilink
          arrow-up
          1
          ·
          2 years ago

          Touch does one thing from a “contract” perspective:

          Ensure the timestamp of <file> is <now>