[Toybox] [PATCH 1/2] tar: don't recurse into excluded directories

Rob Landley rob at landley.net
Tue Jun 9 13:11:18 PDT 2020



On 6/9/20 10:10 AM, William Djupström via Toybox wrote:
> On 09/06 09:56, Rob Landley wrote:
>> I applied this locally, but what's a test case?
>>
>>   $ mkdir -p boing/subb/ping
>>   $ tar cvf boing.tar boing --exclude sub
>>   boing/
>>   boing/subb/
>>   boing/subb/ping/
>>   $ tar tvf boing.tar
>>   drwxr-xr-x landley/landley   0 2020-06-09 09:50 boing/
>>   drwxr-xr-x landley/landley   0 2020-06-09 09:50 boing/subb/
>>   drwxr-xr-x landley/landley   0 2020-06-09 09:50 boing/subb/ping/
>>   $ tar cvf boing.tar boing --exclude subb
>>   boing/
>>   boing/subb/
>>   boing/subb/ping/
> 
> --exclude takes in a file containing exclusions

According to https://www.gnu.org/software/tar/manual/html_node/exclude.html
that's --exclude-from ?

Still with the host tar:

  $ mkdir -p boing/splat/bang
  $ echo splat > splat.txt
  $ tar cvf boing.tar boing --exclude splat.txt
  boing/
  boing/splat/
  boing/splat/bang/
  $ tar tf boing.tar
  boing/
  boing/splat/
  boing/splat/bang/

Hmmm...

  $ tar cvf boing.tar boing --exclude splat.txt
  boing/
  boing/splat/
  boing/splat/bang/
  $ echo boing/splat > splat.txt
  $ tar cvf boing.tar boing --exclude splat.txt
  boing/
  boing/splat/
  boing/splat/bang/

  $ echo splat > splat.txt
  $ tar cvf boing.tar boing --exclude-from splat.txt
  boing/
  boing/splat/
  boing/splat/bang/

>   $ mkdir -p skip/dir
>   $ chmod 000 skip/dir
>   $ ./toybox tar --exclude <(echo skip) -cf test.tar skip
>   tar: skip/dir: Permission denied
>   $ echo $?
>   1

That's another example of --exclude failing, which I've provided plenty of. The
behavior of that command is no different with or without the --exclude argument.

Can you show me an example of --exclude _working_?

Rob



More information about the Toybox mailing list