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

Re: modifiers applied after e qualifier but before oe?



On Mon, Aug 2, 2021 at 9:27 AM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> It's probably intended so that the result of ordering is on the
> modified result rather than on the original path.  I do find it
> surprising that it's not mentioned anywhere, though.

I wonder if we need a section on the order of events for globbing,
akin to the "Rules" section for parameter expansion.

What's going on here is that all of the orderings to be applied to a
given filename generation (glob) are collected as the expression is
parsed, and then applied at the very end after everything else has
modified the result.  This is why the doc notes that you can't have
more than 12 sort operations on any glob, and it confirms that you
can't change what's seen as the incoming value of $REPLY by the 'oe'
code block.

However, if for some reason you need to do this all in the glob, you
could use the first 'e' block to stash a mapping (in a global hash,
say) and then look up that mapping in the 'oe' block to set $REPLY for
the sort.  That means moving the qualifiers into the 'e' block to
assign to $reply, but it's all in one glob.




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