[PATCH] Globs order fixed

Joe Orton joe at manyfish.co.uk
Fri Oct 10 10:51:30 EDT 2008


On Fri, Oct 10, 2008 at 04:36:28AM -0700, Dima Kogan wrote:
> In the current version of cadaver (0.23.2) globs are expanded in
> reverse order. So if my local directory has
> 1.jpg
> 2.jpg
> 3.jpg
> 
> and I do "mput *" in cadaver, the files will be uploaded in
> reverse-numerical order. This is particularly annoying when using
> cadaver to update a picture gallery; the pictures end up being stored
> in reverse-chronological order. The problem stems from the globs being
> expanded in the correct order, but being stored in reverse order. The
> below patch fixes this. It looks like this code wasn't written by the
> cadaver project, but came from elsewhere. Does anybody know where the
> upstream for this code is, so that I can submit a patch there? Thanks!

The code is originally from glibc, IIRC, but is very stale.  Most of the 
lib/* directory needs updating with up-to-date equivalents from gnulib.

w.r.t. your patch, it doesn't actually seem to make much difference 
here, since I get random order from my filesystem anyway.  I agree that 
alpha-sorting the list is probably the right thing to do, though.

Curiously, it looks as if cmdline.c:parse_command() is deliberately 
preventing glob() from sorting the results by passing the GLOB_NOSORT 
flag in, but removing that flag appears to make glob fail completely.  

It seems as if making the glob() invoke qsort() to sort the list is the 
right way to fix this - any chance you could look into that instead?

Regards, Joe




More information about the cadaver mailing list