Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug? Unexpected globbing duplicates
- X-seq: zsh-workers 49754
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: andykluger@xxxxxxxxx
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: Bug? Unexpected globbing duplicates
- Date: Sat, 12 Feb 2022 15:31:26 -0800
- Archived-at: <https://zsh.org/workers/49754>
- In-reply-to: <CAO4D9Ekp5MVe4=6UDwuEMwt5ndRpK4-GaPz7RiDi0q-oHCxAxA@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAO4D9Ekp5MVe4=6UDwuEMwt5ndRpK4-GaPz7RiDi0q-oHCxAxA@mail.gmail.com>
On Sat, Feb 12, 2022 at 12:32 PM <andykluger@xxxxxxxxx> wrote:
>
> I encountered a surprising result while using a glob expression, with
> extended globs enabled, of duplicate resulting elements
> [...]
> % print -rl -- **/**/*
The **/ operator is done by recursive descent, so if it appears more
than once it'll re-scan everything below the second (or third, etc.)
occurrence as the stack is unwound. I suspect it'd make globbing
noticeably slower to check every new result against those already
found. There might be a way to do it just for already-visited
directories that wouldn't add too much overhead.
It might also be possible for the glob-pattern parser to keep track of
when it's already seen **/ or (*/)# and treat further repetitions as
plain */ but that doesn't cover something like (*/)#(bar/)# ... I
suspect it's better to just do what the user wrote, there are other
ways to remove duplicates.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author