[Toybox] alias tar="tar --restrict"
enh
enh at google.com
Thu Apr 11 09:34:28 PDT 2019
On Fri, Apr 5, 2019 at 8:44 PM Rob Landley <rob at landley.net> wrote:
>
> I just added --restrict to require all the tarball's contents to extract under a
> single directory, and the obvious way to use it is the same as ls --color, via
> alias.
>
> $ tar cz linux-4.20 l*.txt > ll.tgz
> $ tar xvf ../ll.tgz --restrict
> ...
> linux-4.20/net/x25/x25_link.c
> linux-4.20/net/x25/x25_proc.c
> linux-4.20/net/x25/sysctl_net_x25.c
> l11.txt
> tar: 'l11.txt' not under '/home/landley/toybox/toy3/tartest/sub/linux-4.20'
> l1.txt
> tar: 'l1.txt' not under '/home/landley/toybox/toy3/tartest/sub/linux-4.20'
> l2.txt
> tar: 'l2.txt' not under '/home/landley/toybox/toy3/tartest/sub/linux-4.20'
> $
>
> Except... tar xvzf not needing dash is because the first argument is treated
> specially, and extra arguments from alias come first. Do you suppose that should
> be the first _non-longopt_ argument, maybe?
>
> Rob
>
> P.S. I made it detect filenames ending in .tgz and such during compression if
> you didn't specify a type. You can work around that via redirect like above
> (hence no filename), but should there also be a command line --stoppit? I'm
> leaning no because gunzip and bunzip2 renaming have similar "this is the
> extension, it means something to me, deal with it", but I should probably ask
> the question. (Extract ignores the filename and checks the signature. This one
> can handle "cat blah.tgz | tar xv", the gnu/dammit one didn't bother to make
> that work.)
>
> P.P.S. The gnu/dammit --restrict is utterly useless, it disables the ! command
> to spawn a subshell when prompting to change tapes. No really. They added this
> in 2005. I reused it because as long as they already added a NOP it means you
> can feed --restrict to both and it'll just work.
i think this came up before, but i think this is pretty much the worst
possible choice with option naming... if i'm thinking of toybox and
i've asked tar to do something, the _last_ thing i want GNU tar to do
is silently ignore what i asked for. i'd much rather GNU tar forced me
to think about whether i actually don't care, or need to do something
special, or need to make sure i'm actually running toybox tar.
(in general the other direction is dangerous too, but in this specific
case i'm pretty sure no-one wants to change tapes on Android or during
an AOSP build --- though you'd be surprised by some of the requests we
do get from folks who don't value hermetic builds quite as much as we
do!)
((it's a shame GNU wasted a good name on a no-op though.))
> _______________________________________________
> Toybox mailing list
> Toybox at lists.landley.net
> http://lists.landley.net/listinfo.cgi/toybox-landley.net
More information about the Toybox
mailing list