zsh-users
 help / color / mirror / code / Atom feed
From: Zach Riggle <zachriggle@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Daniel Shahaf <d.s@daniel.shahaf.name>, Zsh Users <zsh-users@zsh.org>
Subject: Re: Globbing symlinks-to-${glob_qualifier}
Date: Wed, 18 Aug 2021 21:32:30 -0500	[thread overview]
Message-ID: <CAMP9c5kJ3CKdM4KiRTtUBuLNewUsH2usW3njqct2RhMOzwf8Jg@mail.gmail.com> (raw)
In-Reply-To: <CAMP9c5nZt0Y+eazUmWJryWR4LwudGkw5RCoBm0z+-nKjdDbYLg@mail.gmail.com>

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@gmail.com> 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@brasslantern.com> wrote:
> >
> > On Tue, Aug 17, 2021 at 8:58 PM Daniel Shahaf <d.s@daniel.shahaf.name> 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.


  parent reply	other threads:[~2021-08-19  2:33 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-18  3:27 Zach Riggle
2021-08-18  3:57 ` Daniel Shahaf
2021-08-18  4:02   ` Bart Schaefer
2021-08-18 13:10     ` Zach Riggle
2021-08-18 15:24       ` Bart Schaefer
2021-08-18 16:48         ` Ray Andrews
2021-08-18 17:23           ` Bart Schaefer
2021-08-18 17:55             ` Ray Andrews
2021-08-18 22:28               ` Which options are really doing anything (Re: Globbing symlinks-to-${glob_qualifier}) Bart Schaefer
2021-08-18 23:27                 ` Ray Andrews
2021-08-19  2:32       ` Zach Riggle [this message]
2021-08-19  4:38         ` Globbing symlinks-to-${glob_qualifier} Lawrence Velázquez
2021-08-19 13:23           ` Daniel Shahaf
2021-08-19 13:25           ` Daniel Shahaf
2021-08-19 14:38             ` Ray Andrews
2021-08-19 13:54           ` Daniel Shahaf
2021-08-19  4:40         ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMP9c5kJ3CKdM4KiRTtUBuLNewUsH2usW3njqct2RhMOzwf8Jg@mail.gmail.com \
    --to=zachriggle@gmail.com \
    --cc=d.s@daniel.shahaf.name \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public 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).