Archive Utility can't open some gzipped text files based on their contents In macOS 10.15.4, Archive Utility is able to open some gzipped ASCII text files but not others, depending on the contents of the text file. For example, this works:

% echo "abc e" | gzip &gt; ok.txt.gz; open ok.txt.gz


But this fails:

% echo "abcde" | gzip &gt; bad.txt.gz; open bad.txt.gz


The second example shows an error in Archive Utility: "Unable to expand 'bad.txt.gz' into 'folder'. (Error 79 - Inappropriate file type or format.)"



I'm trying to figure out:


Is this a bug in Archive Utility, or am I somehow misusing the gzip format?
Assuming it's a bug, what is the bug? Which files are allowed and which aren't?


Why I believe this is specific to Archive Utility on 10.15:


10.14 and 10.13 don't seem to have this problem; the files open normally.
The bytes of the gzip files created on 10.15 seem to match ones created elsewhere, and open normally with gunzip on 10.15.


Text file contents that work or don't work:


Text files without spaces don't work, such as "abcdefghijklmnopqrstuvwxyz"
Text files with spaces at the end don't work, such as "abcdefghijklmnopqrstuvwxyz "
Text files with internal spaces do work, such as "abcdefghijklmnopqrstuvwxy z"
Text files without spaces but shorter than five characters do work, such as "abcd"


What could be going on?
Someone in another forum sleuthed this out. If you run Archive Utility in the terminal, it shows a more complete error message:

Error unarchiving Error Domain=NSPOSIXErrorDomain Code=79 "Inappropriate file type or format" (Missing type keyword in mtree specification) 


Turns out Archive Utility on Catalina is misdetecting text files as mtree files, which is a documented way to misconfigure libarchive (bug 1; bug 2).

This means, in addition to Archive Utility on 10.15.4 failing to decompress some simple text files like "hello", it will also do surprising things with text files that match the mtree format. For example, decompressing "hello type=dir" will create a directory that can only be deleted with sudo:

% echo "hello type=dir" | gzip &gt; hello.txt.gz; open hello.txt.gz
% ls -l
total 8
d---------  2 jcushman  staff  64 Apr 20 09:36 hello
-rw-r--r--@ 1 jcushman  staff  35 Apr 20 09:36 hello.txt.gz