Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: <x-y> globing pattern doesn't sort?



Louis-David Mitterrand wrote:
> I just tried that:
> 
> % bzcat ../patch-2.6.9-rc1.bz2 ../patch-2.6.9-rc1-bk<1-19>.bz2<TAB>
> 
> and obtained:
> 
> bzcat ../patch-2.6.9-rc1.bz2 ../patch-2.6.9-rc1-bk10.bz2 ../patch-2.6.9-rc1-bk11.bz2 ../patch-2.6.9-rc1-bk12.bz2 ../patch-2.6.9-rc1-bk13.bz2 ../patch-2.6.9-rc1-bk14.bz2 ../patch-2.6.9-rc1-bk15.bz2 ../patch-2.6.9-rc1-bk16.bz2 ../patch-2.6.9-rc1-bk17.bz2 ../patch-2.6.9-rc1-bk18.bz2 ../patch-2.6.9-rc1-bk19.bz2 ../patch-2.6.9-rc1-bk1.bz2 ../patch-2.6.9-rc1-bk2.bz2 ../patch-2.6.9-rc1-bk3.bz2 ../patch-2.6.9-rc1-bk4.bz2 ../patch-2.6.9-rc1-bk5.bz2 ../patch-2.6.9-rc1-bk6.bz2 ../patch-2.6.9-rc1-bk7.bz2 ../patch-2.6.9-rc1-bk8.bz2 ../patch-2.6.9-rc1-bk9.bz2

Is it the order of the expansions that surprised you. It often helps us
understand a point like this if you state what you expected to obtain.

> which really suprised my as I thought the whole point of the <-> pattern
> was to allow for an ordered sequence to be returned (contrary to a
> simple *).
> 
> Am I mistaken in that belief?

<-> doesn't expand a sequence in order. Like *, it is just matching
filenames except it looks for a number within a range. Files are matched
and then sorted.

You could use {1..19} for an ordered expansion but that expands
unconditionally: there doesn't need to be existing files with each name
in the sequence.

Alternatively, you can use the (n) glob qualifier to sort the
expansions numerically:
  patch*(n)

Oliver



Messages sorted by: Reverse Date, Date, Thread, Author