zsh-users
 help / color / mirror / code / Atom feed
From: Zach Riggle <zachriggle@gmail.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Globbing symlinks-to-${glob_qualifier}
Date: Tue, 17 Aug 2021 22:27:19 -0500	[thread overview]
Message-ID: <CAMP9c5mm1XnECVcGriaL7v0z23MAUijGYM-nVuoqMCgS2s-Biw@mail.gmail.com> (raw)

Hello guys!

----

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.

----

After the (surprising!) success of my earlier message, I figured this
was worth asking.

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.

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

I also managed to find the bit on the ":" qualifier, after which
everything is treated as a modifier (e.g. "ls -d *(@:A)" passes the
full path of each symlink to "ls").  This should probably be featured
more prominently in the documentation, like the other qualifiers.

I looked at "14.8.7 Glob Qualifiers" and the third paragraph is a bit
hard for me to grok**. For context, I do have the 'extendedglob'
option set.

> If the option EXTENDED_GLOB is set, a different syntax for glob qualifiers is available, namely ‘(#qx)’ where x is any of the same glob qualifiers used in the other format.

I was able to chain things together and get the glob operation to
succeed, but couldn't produce anything of use.

This works to show all things that are (1) files and (2) executable
files -- but not any better than (*) by itself.

    $ ls -lad *(#q*.)

Trying multiple specifiers for symlink-and-directory does not work.

    $ ls -lad *(#q@/)
    ... No such file or directory

Further down, after the documentation, there is discussion of the "-"
qualifier, which can be used (per the example):

> ls -ld -- *(-/)
> lists all directories and symbolic links that point to directories

This is ALMOST what I want -- but I just want the "symbolic links that
point to directories" part.

**UPDATE**: A bit more fiddling around, by combining (#qx) and (-/)
and I ended up with this, which does exactly what I want!

    $ ls -la *(#q-/)(@)

Hurray!  It also works-as-expected with this form for files:

    $ ls -la *(#q-.)(@)

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

Zach Riggle


             reply	other threads:[~2021-08-18  3:28 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-18  3:27 Zach Riggle [this message]
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

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=CAMP9c5mm1XnECVcGriaL7v0z23MAUijGYM-nVuoqMCgS2s-Biw@mail.gmail.com \
    --to=zachriggle@gmail.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).