help / color / mirror / code / Atom feed
From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: glob executable vs. non executable
Date: Thu, 27 Oct 2022 14:44:33 -0700	[thread overview]
Message-ID: <c4d4b6ca-3e11-531f-fd9f-5a16c53625f0@eastlink.ca> (raw)
In-Reply-To: <05065e8d-8bf7-4ca2-b89d-1151348cb30d@app.fastmail.com>

On 2022-10-27 13:02, Lawrence Velázquez wrote:
> What about binary files that you cannot execute, like libraries,
> images, audio files, tarballs, etc.?
Yeah, I'm trying to cover all the possibilities.  'file' seems the most 
informative but even then there's more to say.
>      all_unx=( (#i)${~1}(N.^*) )
> The ${~spec} form enables GLOB_SUBST for that substitution.
Thanks, that handles it.
> It's not a bad pattern; the qualifiers are just impossible to
> satisfy.  You are asking for regular executable files that are ALSO
> symbolic links.
Ah! It's a test in series not in parallel.  I thought it was an OR, but 
it's an AND.
> Strictly speaking, you could use a comma to separate the "*" and
> "@" qualifiers; this denotes a logical disjunction.  (Juxtaposition
> indicates a conjunction.)
>      all_unx=( (#i)${~1}(N*,@) )
Very good.  I couldn't find any documentation on that.
> However, as I said earlier, it is not useful to consider symbolic
> links "executable"

In my head the word might be 'actionable'.  Type some word at the prompt 
and press ENTER and sometimes something happens.  What I'm trying to 
nail down is all the possibilities and what sorts of species they can 
be.  In that frame of mind, a symlink is actionable so I consider it in 
the same category as any other actionable word.

> , so this result does not make any sense.  You
> probably want to find executables and *symbolic links that point
> to executables*.  This can be done with the "-" qualifier, which
> causes the subsequent qualifiers to operate on symbolic links'
> targets instead of on the links themselves.
>      all_unx=( (#i)${~1}(N-*) )
> Using "*" with "-" more or less covers this.
Excellent, this gives me bones to chew on.  Fantastic power there if I 
can learn to use it.
> (1)  Whether a file is a "text file" is a characteristic of its
>       contents and is not appropriate for a glob qualifier.
Quite right.  I see it the moment you say it.  Different job.
> (2)  Determining whether a file is "text" is more complicated than
>       you seem to think.
I know it.  'file' seems to use three separate tests.  So, come to think 
of it, that's a difficult thing to ask of the shell.  One might suppose 
it's easy but it ain't.
> (3)  If you have a utility or some code that does that to your
>       satisfaction, you can use it to filter the globbing results
>       via the "e" qualifier.

> (4)  The "T" qualifier is already in use.

... just a 'for instance'.  But I see now that this is hardly the 
shell's business and even if it was, it would be one of those 
conditional expressions: > [ -T "$some_file" ] && echo "That does appear 
to be a text file but don't be too sure." <

Anyway my function works well and I rely on it, but there's always the 
next little gotcha.

Thanks Lawrence, you guys are so informative.  Learning zsh by myself 
would be next to impossible.

  reply	other threads:[~2022-10-27 21:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-27 15:41 Ray Andrews
2022-10-27 20:02 ` Lawrence Velázquez
2022-10-27 21:44   ` Ray Andrews [this message]
2022-10-27 23:19     ` Lawrence Velázquez
2022-10-27 23:39       ` Ray Andrews

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=c4d4b6ca-3e11-531f-fd9f-5a16c53625f0@eastlink.ca \
    --to=rayandrews@eastlink.ca \
    --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).