Given that barf is already using the filename to indicate the compression, why not just move the final byte of the file into the filename instead? Something like,
head -c -1 "$file" > "$file$(tail -c1 "$file")"
EDIT: Obviously this has the corner case of null bytes
Is he just moving bytes from the file into the file name? He should count the increased size of the file name in the size of the compressed file otherwise he’s not counting all of the essential data you need for the decompression.
You can decompress a gzip file without the file name (think about tar using a pipe.)
In this very specific case because the author, Matt Mahoney, is one of the most respected experts in the field of lossless data compression. But yeah, in some case the difference is hard to tell.
https://cs.fit.edu/~mmahoney/compression/barf.html
Of course, there's a catch.