zsh-users
 help / color / mirror / code / Atom feed
* Globbing symlinks-to-${glob_qualifier}
@ 2021-08-18  3:27 Zach Riggle
  2021-08-18  3:57 ` Daniel Shahaf
  0 siblings, 1 reply; 17+ messages in thread
From: Zach Riggle @ 2021-08-18  3:27 UTC (permalink / raw)
  To: Zsh Users

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


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2021-08-19 14:39 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-18  3:27 Globbing symlinks-to-${glob_qualifier} 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

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