help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zach Riggle <zachriggle@gmail.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:40:48 -0700	[thread overview]
Message-ID: <CAH+w=7agRx_1PWPdU2WJ0BGEXXhSZZ8X5SoYtEg97bdd66CF9Q@mail.gmail.com> (raw)
In-Reply-To: <CAMP9c5kJ3CKdM4KiRTtUBuLNewUsH2usW3njqct2RhMOzwf8Jg@mail.gmail.com>

On Wed, Aug 18, 2021 at 7:32 PM Zach Riggle <zachriggle@gmail.com> wrote:
> How can I glob for all symlinks-to-symlinks-to-a-directory (etc)?

You can run a function from a glob qualifier by using the "e"
qualifier or its shortcut "+".  So it's possible to do almost anything
you want, it just might be slow.

This one shouldn't be too laggy.

zmodload zsh/stat b:zstat
function _ { # Chosen as a short name
  local -a L
  zstat -A L +link $REPLY && [[ -h $L ]]

# Print all symlinks to symlinks
print -r -- *(+_)
# Print symlinks to symlinks to directories
print -r -- *(+_-/)

In the last case (as Lawrence noted in a message that came in while I
was typing this) the "-" is going to run down the entire symlink chain
to find the ultimate target, i.e., you can't tell if there are exactly
two symlinks, just that there are at least two.

      parent reply	other threads:[~2021-08-19  4:41 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       ` 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 [this message]

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='CAH+w=7agRx_1PWPdU2WJ0BGEXXhSZZ8X5SoYtEg97bdd66CF9Q@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=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).