help / color / mirror / code / Atom feed
From: "Daniel Shahaf" <d.s@daniel.shahaf.name>
To: "Zach Riggle" <zachriggle@gmail.com>, "Zsh Users" <zsh-users@zsh.org>
Subject: Re: Globbing symlinks-to-${glob_qualifier}
Date: Wed, 18 Aug 2021 03:57:50 +0000	[thread overview]
Message-ID: <8e20a9ea-d705-4a1f-97ca-ff6b809f6a92@www.fastmail.com> (raw)
In-Reply-To: <CAMP9c5mm1XnECVcGriaL7v0z23MAUijGYM-nVuoqMCgS2s-Biw@mail.gmail.com>

Zach Riggle wrote on Wed, 18 Aug 2021 03:27 +00:00:
> UPDATE: Managed to figure it out on my own (see update at the end),
> but thought this was still worth posting in case the mail archives get
> indexed by Google.


> My question is whether there's a way to combine the @ with any of the
> other glob qualifiers -- i.e. to glob for symlinks-to-directories or
> symlinks-to-executables.

That'll be «*(@-/)» and «*(@-*)» respectively.  The «@» tests the directory entry
for being a symlink, then «-» flips to "testing the directory entry,
unless it's a symlink in which case test what it points to", and «/»
tests the symlink's target for being a directory.

Does not require extendedglob.

Under the hood, «-» simply flips between testing the results of lstat(2)
and stat(2).

> Many of the glob qualifiers are specific, simple, and well-documented
> -- *(*) for executables, *(/) for directories, *(.) for files, and
> *(@) for symlinks.
> I tried the obvious combinations, but these didn't work. Not surprising.
>     $ ls -lad *(/)  # Shows all directories
>     $ ls -lad *(@/) # Error
>     $ ls -lad *(/@) # Error

Not an error; just zero matches.  That's not the same thing.

These particular commands will _always_ have zero matches, because no
directory entry can be both a symlink and a directory.  (A dirent can be
a symlink _to_ a directory, but a symlink can't _itself_ be a directory.)

> Ultimately, I managed to sort it out and everything works how I want!

Thanks for sharing your steps!  It's helpful for our next design discussions :)


  reply	other threads:[~2021-08-18  3:59 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 [this message]
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       ` Globbing symlinks-to-${glob_qualifier} Zach Riggle
2021-08-19  4:38         ` 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:

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

  git send-email \
    --in-reply-to=8e20a9ea-d705-4a1f-97ca-ff6b809f6a92@www.fastmail.com \
    --to=d.s@daniel.shahaf.name \
    --cc=zachriggle@gmail.com \
    --cc=zsh-users@zsh.org \


* 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


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).