Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Globbing symlinks-to-${glob_qualifier}
Not sure what etiquette is for forking a thread on mailing lists, but
I didn't want to disturb the other discussion on flags/options.
My original question was: "How can I glob for all symlinks to
{directories,files,executables}" and while I did find my own way to
*an* answer, you guys were very helpful at finding a much *better*
answer.
I have a rather ridiculous follow up (no practical application, just
curious how / if it can be done):
How can I glob for all symlinks-to-symlinks-to-a-directory (etc)? I
expected symlink-to-symlink might be *(@-@) but despite looking quite
cute and similar to either Kirby or Jigglypuff (I can't decide).
However, it doesn't in fact work and I'm just curious if there's more
voodoo in that box.
Zach Riggle
Zach Riggle
On Wed, Aug 18, 2021 at 8:10 AM Zach Riggle <zachriggle@xxxxxxxxx> wrote:
>
> > That'll be «*(@-/)» and «*(@-*)» respectively.
>
> Thanks for the info (and hello to France!)
>
> Definitely easier to read and reason about than *(#q-.)(@)
>
> > Under the hood, «-» simply flips between testing the results of lstat(2) and stat(2).
>
> Ah, that's useful information! Love these implementation details.
>
> > Not an error; just zero matches. That's not the same thing.
>
> You're definitely correct, my mistake in terminology. I'm lucky that
> I got "qualifier" and "modifier" correct (I think!)
>
> > It does become an error when NOMATCH is set
>
> That's neat!
>
> The "error" that I got was just '/bin/ls' complaining that there is no
> file named e.g. '*(@/)' since the glob didn't find anything (and I
> don't have nullglob or nomatch set). For me, it often helps to employ
> Python to see exactly what's being passed in:
>
> $ python -c 'import sys; print(sys.argv[1:])' *asdfasdfasdf*
> ['*asdfasdfasdf*']
>
> $ python -c 'import sys; print(sys.argv[1:])' *(@/)
> ['*(@/)']
>
> $ python -c 'import sys; print(sys.argv[1:])' *(@-/)
> ['pwndbg', 'pwntools']
>
> Turning on nomatch does indeed throw an error from zsh.
>
> $ setopt nomatch
>
> $ python -c 'import sys; print(sys.argv[1:])' *(@/)
> zsh: no matches found: *(@/)
>
> Interestingly, it appears that nullglob takes priority over nomatch.
> Yet another "Today I Learned."
>
> $ setopt nullglob nomatch
>
> $ python -c 'import sys; print(sys.argv[1:])' *(@/)
> []
>
> Zach Riggle
>
>
> On Tue, Aug 17, 2021 at 11:03 PM Bart Schaefer
> <schaefer@xxxxxxxxxxxxxxxx> wrote:
> >
> > On Tue, Aug 17, 2021 at 8:58 PM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> > >
> > > Zach Riggle wrote on Wed, 18 Aug 2021 03:27 +00:00:
> > > > $ ls -lad *(@/) # Error
> > > > $ ls -lad *(/@) # Error
> > >
> > > Not an error; just zero matches.
> >
> > It does become an error when NOMATCH is set, but not because there's
> > anything illegal about writing that qualifier.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author