On 10/8/22 03:11, Rob Landley wrote: > On 10/7/22 18:01, enh via Toybox wrote: >> continuing to be a moving target... >> >> the kernel folks are about to start using tar --wildcards, which i also >> hadn't >> heard of. >> (https://android-review.googlesource.com/c/kernel/build/+/2241508/7..9/kleaf/impl/abi/extracted_symbols.bzl#73) > > Oh joy.
Trying to work out what this feature actually does, and it's _not_ applying to the actual filenames listed on the command line, it seems like it's only applying to the inclusion/exclusion stuff? Which simplifies things enormously because filtering a list of filenames is very different from traversing a filesystem using a path with wildcards in. (Leading up to this I was going "please don't make me pull in glob() or wordexp() out of libc, and it does not. I think. Yet.) >> sounds like that might be a no-op though, asking for the default behavior? >> >> --wildcards >> Use wildcards (default for exclusion). > > No, the default behavior is --no-wildcards. For inclusion. For --exclusion it's right the default is wildcards. And the not immediately obvious part is that there IS no --include because that's what it does with leftover arguments. So they're specified differently and behave differently, and that's before you get to command line files listed for archive creation and extraction being _conceptually_ different. > 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 Gag me with a totally awesome spoon. Sigh. I fixed this for sed in commit 891c5520f493 and the same technique can work here. Ugly solution to an ugly problem. Ahem, deep breaths. "Spoon! I like that word, Arthur. Henceforth it shall be my battle cry." (Except that's one of them "Play it again sam" famous misquotes, the ACTUAL quote ala https://www.cbr.com/the-tick-battle-cry-debut-spoon/ was "I like the word. It's got a nice ring to it. Henceforth it will be my battle cry.") Announcer: Welcome to point-and-counterpoint. The Tick: Spoon! Neo: There is no spoon. Announcer: This has been point-and-counterpoint. Rob P.S. https://www.youtube.com/watch?v=G9QKdrMS96Y _______________________________________________ Toybox mailing list [email protected] http://lists.landley.net/listinfo.cgi/toybox-landley.net
