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

Re: Globbing symlinks-to-${glob_qualifier}



> 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