[Toybox] more tar madness

Rob Landley rob at landley.net
Fri Nov 11 16:34:48 PST 2022


On 10/25/22 07:32, Rob Landley wrote:
>> Let's see, what does this apply to...
>> 
>> $ tar tvz --wildcards -f 'toybox-0.8.[0].tar.gz'
>> tar (child): toybox-0.8.[0].tar.gz: Cannot open: No such file or directory
>> tar (child): Error is not recoverable: exiting now
>> tar: Child returned status 2
>> tar: Error is not recoverable: exiting now
>> 
>> Not the archive name. Ok.
>> 
>> $ tar tvz --wildcards -f 'toybox-0.8.0.tar.gz' 'toybox-0.?.0/www/*.png'
>> -rw-rw-r-- root/root     48192 2019-02-08 20:15 toybox-0.8.0/www/toycans.png
>> 
>> And there it is.
> 
> Which is technically an inclusion list. It's just --exclude=PATTERN is an
> argument type but on EXTRACTION include patterns are all remaining untyped
> arguments, but on archive CREATION the remaining untyped arguments are explicit
> file and directory names. Which are processed by various transforms but NOT
> wildcard matching because:
> 
>   $ tar c --wildcards 'w?w' | hd
>   tar: w?w: Cannot stat: No such file or directory
> 
> So yeah, fnmatch() but not glob(). Need a pile of tests, but probably more tests
> than code by character count added to the repo. (Sigh: --wildcards-match-slash
> and --no-wildcards-match slash, SO many tests...)
> 
>> Of course the OTHER question this re-raises is whether lib/args.c needs to know
>> about --no-thingy prefixes. I kinda want to add a "(potato)!" trailing
>> punctuation to say this --longopt can toggle on and off with --no-whatsis, except:
> 
> I do not have the spoons for that infrastructure rewrite right now.
> 
>   $ tar c woot | tar tv --wildcards 'wo?t'
>   -rwxr-xr-x landley/landley  31 2021-02-05 03:15 woot
>   $ tar c woot | tar tv 'wo?t' --wildcards
>   tar: wo?t: Not found in archive
>   tar: Exiting with failure status due to previous errors

$ tar c www/index.html --exclude '*.html' www/roadmap.html | tar tv
lrwxrwxrwx landley/landley   0 2016-08-03 15:23 www/index.html -> news.html

$ tar c www/index.html --no-wildcards --exclude '*.html' --wildcards -T <(echo
www/roadmap.html) | tar tv
lrwxrwxrwx landley/landley   0 2016-08-03 15:23 www/index.html -> news.html
-rw-r--r-- landley/landley 69641 2022-09-20 01:00 www/roadmap.html

Ignoring the fact that --wildcards could be _in_ the -T input (unless you
specify --verbatim-files-from which I did not make up and which toybox tar
basically has hardwired "on" because I dowanna implement control flags
interspersed file lists), I have to record the state off the wildcard flags
(plural, there's at least 3 we care about) at the time the name is added to the
TT.incl or TT.excl list. Meaning the list needs special annotation.

Luckily all this seems localized to the filter() function, but NONE of this is
clearly specified...

Rob

P.S. Although I NOTE that if you DON'T --verbatim-files-from then it says it
does wildcard expansion and word splitting on each argument in the input file.
Not the shell, TAR does it. And in THIS context, that sounds like directory
traversal to resolve dir/*-04*/thing/*.txt

P.P.S. No, I don't know if it reads $IFS for word splitting. Not asking right now.


More information about the Toybox mailing list