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

Re: Globbing symlinks-to-${glob_qualifier}



On Wed, Aug 18, 2021, at 10:32 PM, Zach Riggle wrote:
> 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.

There isn't really a problem unless you go off on a tangent and the
"Subject" field becomes totally irrelevant, in which case you should
have changed it.  Email is (ostensibly) an asynchronous medium, so
there's no need to wait until one exchange settles down before going
back to address a previous point, as long as you quote properly to
maintain context.

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

Hm, I thought of another fictional character...

https://en.wikipedia.org/wiki/Billy_the_Puppet

> However, it doesn't in fact work and I'm just curious if there's more
> voodoo in that box.

The zshexpn(1) man page says this...

       -   toggles between making the qualifiers work on symbolic
           links (the default) and the files they point to

...but it would be more accurate if it said "the files they fully
resolve to".  So *(@-@) doesn't give you symlinks that themselves
point to symlinks, it gives you symlinks that *fully resolve to
symlinks*.  AFAICT this only produces results when the symlink chain
is broken.

    % ln -s /bin a
    % ln -s a b
    % ln -s b c
    % ln -s c d
    % printf '<%s>' *(@-/); echo
    <a><b><c><d>
    % printf '<%s>' *(@-@); echo
    zsh: no matches found: *(@-@)
    % rm a
    % printf '<%s>' *(@-@); echo
    <b><c><d>

I'll leave possible solutions to the more daring (and competent).

-- 
vq




Messages sorted by: Reverse Date, Date, Thread, Author