Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Globbing symlinks-to-${glob_qualifier}
- X-seq: zsh-users 26950
- From: Zach Riggle <zachriggle@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>, Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Globbing symlinks-to-${glob_qualifier}
- Date: Wed, 18 Aug 2021 08:10:56 -0500
- Archived-at: <https://zsh.org/users/26950>
- In-reply-to: <CAH+w=7bUS3JZQVwC2jNonn2beL+3957BBAZHURwihyDiPrUC7g@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <CAMP9c5mm1XnECVcGriaL7v0z23MAUijGYM-nVuoqMCgS2s-Biw@mail.gmail.com> <8e20a9ea-d705-4a1f-97ca-ff6b809f6a92@www.fastmail.com> <CAH+w=7bUS3JZQVwC2jNonn2beL+3957BBAZHURwihyDiPrUC7g@mail.gmail.com>
> 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