zsh-users
 help / color / mirror / code / Atom feed
* modifiers applied after e qualifier but before oe?
@ 2021-08-02 14:42 Stephane Chazelas
  2021-08-02 16:27 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Stephane Chazelas @ 2021-08-02 14:42 UTC (permalink / raw)
  To: Zsh Users List

Today I realised that modifiers were applied *before* the
expression in the oe['expression'] glob qualifier was evaluated
(but after the one in e['expression']):

$ echo /etc/issue(e['echo e: $REPLY']oe['echo oe: $REPLY']:t)
e: /etc/issue
oe: issue
issue


Is it as intended? I couldn't find it mentioned in the
documentation.

Is there a way to change that (for oe to see the original path
without modification by modifiers) within a single glob? I tried:

$ echo /etc/issue(#qe['echo e: $REPLY']oe['echo oe: $REPLY'])(#q:t)
e: /etc/issue
oe: issue
issue

didn't help.

If not, I can always do:

$ () { echo $@:t; } /etc/issue(e['echo e: $REPLY']oe['echo oe: $REPLY'])
e: /etc/issue
oe: /etc/issue
issue


That is move the modifiers out of the glob and apply them to
parameter expansion.

-- 
Stephane


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: modifiers applied after e qualifier but before oe?
  2021-08-02 14:42 modifiers applied after e qualifier but before oe? Stephane Chazelas
@ 2021-08-02 16:27 ` Bart Schaefer
  2021-08-02 21:19   ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2021-08-02 16:27 UTC (permalink / raw)
  To: Zsh Users List

On Mon, Aug 2, 2021 at 7:42 AM Stephane Chazelas <stephane@chazelas.org> wrote:
>
> Is it as intended? I couldn't find it mentioned in the
> documentation.

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.

> Is there a way to change that (for oe to see the original path
> without modification by modifiers) within a single glob?

I would expect not.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: modifiers applied after e qualifier but before oe?
  2021-08-02 16:27 ` Bart Schaefer
@ 2021-08-02 21:19   ` Bart Schaefer
  0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2021-08-02 21:19 UTC (permalink / raw)
  To: Zsh Users List

On Mon, Aug 2, 2021 at 9:27 AM Bart Schaefer <schaefer@brasslantern.com> 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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-02 21:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-02 14:42 modifiers applied after e qualifier but before oe? Stephane Chazelas
2021-08-02 16:27 ` Bart Schaefer
2021-08-02 21:19   ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).