[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#258262: ITP: sortdir -- wrapper program to make files show up in sorted order



On Mon, 2004-07-12 at 21:35, Nicolas Boullis wrote:
> On Mon, Jul 12, 2004 at 04:11:51PM +0200, Gergely Nagy wrote:
> > > > > This small wrapper program will make other programs see files and
> > > > > directories in a consistent, sorted order. This is e.g. usefull if you 
> > > > > want your tarballs to be a bit more rsyncable.
> > > > 
> > > > How is this better than tar cvf foo.tar $(find foo | sort) ?
> > > 
> > > I guess that if you try to do it for something ass big as the kernel
> > > source tree (for example), you would exceed both the maximal number of
> > > arguments and the maximal length of the command line. Moreover, that
> > > would fail with oddly-named files/directories that contain spaces,
> > > carriage returns or tabs in their name...
> > 
> > That's what find foo | sort | xargs tar rvf foo.tar is for. Handles
> > spaces, no command-line length overflow, no nothing, and does the same,
> > methinks.
> 
> I guess you should add '\! -type d' to your find command. Anyway, that
> won't work if some file/directory contains a newline symbol. (Using this
> would be stupid, but it's legal.)

Okay, I don't have an easy solution for that in pure shell. It's still
doable with some perl-foo (for example). But then... How many people are
out there who have newlines in filenames and want an easily rsyncable
tarball? Or give their files to some program, sorted, that can't sort it
itself?

I believe that those who know how to use rsync and actually want their
tarballs to be rsyncable, can come up with a perl script in no time that
sorts the output of find -print0 (just slurp the input into a big
scalar, split it into an array by \0, and sort it, then print it,
bingo), so they won't have much use for sortdir. Those, who have files
with embedded newlines are either advanced users, or they use GUI tools,
and don't care about commandline stuff like sortdir.

To get back to my original point: why is sortdir ever useful? Outside of
making rsyncable tarballs, which can be trivially done without it.




Reply to: