There I said it !

  • LemoineFairclough@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    2
    ·
    7 hours ago

    I think that providing an exit status that is not 0 when zcat is used with an uncompressed file is useful. Though my opinion is less strong regarding whether it should write more text after an error occurred, it’s probably more useful for a process to terminate quickly when an error occurred rather than risk a second error occurring and making troubleshooting harder.

    I think that trying to change any existing documented features of widely used utilities will lead to us having less useful software in the future (our time is probably better spent making new programs and new documentation): https://www.jwz.org/doc/worse-is-better.html https://en.wikipedia.org/wiki/Worse_is_better

    • interdimensionalmeme@lemmy.mlOP
      link
      fedilink
      arrow-up
      1
      ·
      4 hours ago

      Not improving existing software leads to stagnation.

      It’s certainly a good part of why so much of linux is an awkward kludgy idiosyncratic mess to use.

      Whatever the first implementation does ends up being a suicide pact by default.

      Another option is to change cat to auto decompress compressed files, instead of printing gibberish.

  • Malfeasant@lemm.ee
    link
    fedilink
    arrow-up
    8
    ·
    12 hours ago

    How do you propose zcat tell the difference between an uncompressed file and a corrupted compressed file? Or are you saying if it doesn’t recognize it as compressed, just dump the source file regardless? Because that could be annoying.

    • interdimensionalmeme@lemmy.mlOP
      link
      fedilink
      arrow-up
      3
      arrow-down
      1
      ·
      11 hours ago

      Even a corrupt compressed files has a very different structure relative to plain text. “file” already has the code to detect exactly which.

      Still, failing on corrupted compression instead of failing on plaintext would be an improvement.

  • elmicha@feddit.org
    link
    fedilink
    arrow-up
    24
    ·
    24 hours ago

    I agree. zgrep also works for uncompressed files, so we could use e.g. zgrep ^ instead of zcat.

  • allywilson@lemmy.ml
    link
    fedilink
    arrow-up
    15
    ·
    24 hours ago

    Yeah, it’s a pain. Leads to bad one liners:

    for i in $(ls); do zcat $i || cat $i; done

    • interdimensionalmeme@lemmy.mlOP
      link
      fedilink
      arrow-up
      6
      arrow-down
      1
      ·
      edit-2
      24 hours ago

      Thanks !

      But still we shouldn’t have to resort to this !

      Also, can’t get the output through pipe

      for i in $(ls); do zcat $i || cat $i; done | grep mysearchterm

      this appears to work

      find . -type f -print0 | xargs -0 -I{} sh -c 'zcat "{}" 2>/dev/null || cat "{}"' | grep "mysearchterm"

      Still, that was a speed bump that I guess everyone dealing with mass compressed log files has to figure out on the fly because zcat can’t read uncompressed files ! argg !!!

      for i in $(ls); do zcat $i 2>/dev/null || cat $i; done | grep mysearchterm