[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Glob expansion sort order
From: |
Adam Vodopjan |
Subject: |
Re: Glob expansion sort order |
Date: |
Sun, 10 Sep 2023 23:12:23 +0300 |
User-agent: |
Mozilla Thunderbird |
On 10/09/2023 22:15, Philip Couling wrote:
> Is the result of glob expansion sorted?
No
>
> Assuming regexp is installed, you can loop through files:
> for file in (hd0,gpt1)/foo/*
> do
> echo $file
> done
>
> I'd like to ensure the loop always executes in reverse text sort order
> (foo, bar not bar, foo). So far experiments have all resulted in that
> order but I'm not sure if I'm seeing the result of reading files in the
> order that the file system happens to have recorded them, or if grub is
> deliberately sorting them.
It is the so called "directory order", no sorting
>
> If it's not sorted, how can I sort them?
I've implemented sorting for the GLIM project. You can grasp the idea here
https://github.com/thias/glim/blob/df24e34bc45d5136fe2499f10d5af50d8e8c6353/grub2/grub.cfg#L60-L109