more uses for mode 000 (will be: cat -v considered harmful)

Steve Summit scs at adam.mit.edu
Tue Feb 12 15:33:41 AEST 1991


In article <1991Feb10.221410.2345 at athena.mit.edu>, I wrote:
>	chmod 000 $HOME/subdir/hugedir
>	cd $HOME
>	tar c .
>...
>Admittedly, there are other ways of solving these problems...

In article <CLARK.91Feb11160645 at discord.cme.nist.gov> clark at cme.nist.gov (Steve Clark) writes:
>cd $HOME
>echo ./subdir/hugedir | tar cX - .
>
>Is this not portable?

Well, I did imply that there were other ways.

This will probably spark a big "cat -v considered harmful"
flamefest, but I'll opine that adding this tar X option wasn't
very worthwhile.  The right way to exclude files matching some
pattern is

	tar c `find . -print | grep -v pattern`

Now, Unix is far less restrictive than most operating systems on
things like command line length limitations, but this is one case
where you can overload even the generous allotments that the
shells (and exec) give you.  Therefore, a wrinkle that *is* a
worthwhile addition to tar is a way to read a list of filenames
from a file, or from standard input.  I once implemented this as

	tar c -R file_of_files

('R' for recursive; I don't remember if it was my idea or if I
patterned it after somebody else's.)  GNU tar has the same idea,
but they named it -T, and it does work with `-' for stdin.  It
seems to me I've seen a third option, for reading filenames from
stdin only, which didn't involve a special flag character;
perhaps it was something like

	tar c -

In any case, with an option like this we can do something like

	find . -print | grep -v pattern | tar c -T -

and there's no need to build regexp handling into tar.  (Sure,
with a regexp library it's easy enough, but why bother?)

I don't know how widespread -T is (or that third option I can't
remember).  I see that BSD tar has neither -T nor -X.

                                            Steve Summit
                                            scs at adam.mit.edu



More information about the Comp.unix.internals mailing list