zsh-users
 help / color / mirror / code / Atom feed
* Glob Qualifier Yn enables short-circuit mode behaves oddly
@ 2022-03-11 13:09 zzapper
  2022-03-11 13:50 ` Mikael Magnusson
  0 siblings, 1 reply; 4+ messages in thread
From: zzapper @ 2022-03-11 13:09 UTC (permalink / raw)
  To: Zsh-Users List

[-- Attachment #1: Type: text/plain, Size: 371 bytes --]

Hi

 > print *(.omY3)

notebash.txt note132.txt note020.txt

I don't know why it's selected those 3 files but it always does


Yn

    enables short-circuit mode: the pattern will expand to at most n
    filenames. If more than n matches exist, only the first n matches in
    directory traversal order will be considered.

    Implies oN when no oc qualifier is used.



[-- Attachment #2: Type: text/html, Size: 836 bytes --]

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

* Re: Glob Qualifier Yn enables short-circuit mode behaves oddly
  2022-03-11 13:09 Glob Qualifier Yn enables short-circuit mode behaves oddly zzapper
@ 2022-03-11 13:50 ` Mikael Magnusson
  2022-03-11 14:12   ` zzapper
  0 siblings, 1 reply; 4+ messages in thread
From: Mikael Magnusson @ 2022-03-11 13:50 UTC (permalink / raw)
  To: zzapper; +Cc: Zsh-Users List

On 3/11/22, zzapper <zsh@rayninfo.co.uk> wrote:
> Hi
>
>  > print *(.omY3)
>
> notebash.txt note132.txt note020.txt
>
> I don't know why it's selected those 3 files but it always does
>
>
> Yn
>
>     enables short-circuit mode: the pattern will expand to at most n
>     filenames. If more than n matches exist, only the first n matches in
>     directory traversal order will be considered.
>
>     Implies oN when no oc qualifier is used.

You've included the answer in your mail, Y3 will stop looking at files
after finding 3 in directory traversal order, those 3 files are then
sorted according to their modification timestamp. If you want to
consider all files in the directory, use [3] instead of Y3.

-- 
Mikael Magnusson


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

* Re: Glob Qualifier Yn enables short-circuit mode behaves oddly
  2022-03-11 13:50 ` Mikael Magnusson
@ 2022-03-11 14:12   ` zzapper
  2022-03-11 14:34     ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: zzapper @ 2022-03-11 14:12 UTC (permalink / raw)
  To: Mikael Magnusson, Zsh-Users List


On 11/03/2022 13:50, Mikael Magnusson wrote:
> On 3/11/22, zzapper <zsh@rayninfo.co.uk> wrote:
>> Hi
>>
>>   > print *(.omY3)
>>
>> notebash.txt note132.txt note020.txt
>>
>> I don't know why it's selected those 3 files but it always does
>>
>>
>> Yn
>>
>>      enables short-circuit mode: the pattern will expand to at most n
>>      filenames. If more than n matches exist, only the first n matches in
>>      directory traversal order will be considered.
>>
>>      Implies oN when no oc qualifier is used.
> You've included the answer in your mail, Y3 will stop looking at files
> after finding 3 in directory traversal order, those 3 files are then
> sorted according to their modification timestamp. If you want to
> consider all files in the directory, use [3] instead of Y3.
>

MM,

So what then is traversal order?

zzapper



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

* Re: Glob Qualifier Yn enables short-circuit mode behaves oddly
  2022-03-11 14:12   ` zzapper
@ 2022-03-11 14:34     ` Peter Stephenson
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 2022-03-11 14:34 UTC (permalink / raw)
  To: zzapper, Mikael Magnusson, Zsh-Users List

> On 11 March 2022 at 14:12 zzapper <zsh@rayninfo.co.uk> wrote:
> On 11/03/2022 13:50, Mikael Magnusson wrote:
> > On 3/11/22, zzapper <zsh@rayninfo.co.uk> wrote:
> >> Hi
> >>
> >>   > print *(.omY3)
> >>
> >> notebash.txt note132.txt note020.txt
> >>
> >> I don't know why it's selected those 3 files but it always does
> >>
> >>
> >> Yn
> >>
> >>      enables short-circuit mode: the pattern will expand to at most n
> >>      filenames. If more than n matches exist, only the first n matches in
> >>      directory traversal order will be considered.
> >>
> >>      Implies oN when no oc qualifier is used.
> > You've included the answer in your mail, Y3 will stop looking at files
> > after finding 3 in directory traversal order, those 3 files are then
> > sorted according to their modification timestamp. If you want to
> > consider all files in the directory, use [3] instead of Y3.
> 
> So what then is traversal order?

It's totally arbitrary -- whatever the OS throws up.  That's the point
of this optimisation --- you've told the shell you don't care what's
there, you're just interested in there being something.  I think the
technical answer is likely to be "inode order".

Typical usage of this feature is with a 1 to grab one file that might
be the only one (but if it isn't you don't care).

pws


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

end of thread, other threads:[~2022-03-11 14:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-11 13:09 Glob Qualifier Yn enables short-circuit mode behaves oddly zzapper
2022-03-11 13:50 ` Mikael Magnusson
2022-03-11 14:12   ` zzapper
2022-03-11 14:34     ` Peter Stephenson

Code repositories for project(s) associated with this 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).