Hello Rob,

Is there a way to create an empty tar archive with toybox? I tried:

$ ./toybox tar czf foo.tar.gz -T /dev/null
tar: empty archive

It seems that this comes from from
https://github.com/gfto/toybox/blob/75ebbd1571c85a06c0f4767beb7c20a19068f0b6/toys/pending/tar.c#L763
.

Background The reason I ask is that I want to do this:

tar czf out.tar.gz -T filelist.txt

But filelist.txt could be empty and I expect it to create an empty archive.
If toybox can't create empty archive when -T is empty, I have to use the
following workaround instead (untested pseudocode):

if [ -s filelist.txt ]; then
    tar czf out.tar.gz -T filelist.txt
else
    gzip < /dev/null > out.tar.gz
fi

... which works, but it is not quite gracefully handled IMO.

As a reference, GNU tar 1.35 does the following:

# This fails
$ tar czf out.tar.gz
tar: Cowardly refusing to create an empty archive

# This succeeds
$ tar czf out.tar.gz -T /dev/null

-- 
Hong, Yifan <e...@google.com>
_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to