Simple--first, test whether a stream is binary. You can't use -B on a stream because it consumes the bytes. If it is binary, see if it is a known compressed file type. Then redirect the stream to an appropriate decompressor program.
Yes, I *could* store the bytes I've read, but things would be much simpler if I could unget them. I could also write an external file, but I don't want to risk a security flaw. (This is for email.) | [reply] |