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

Re: glob executable vs. non executable



On Thu, Oct 27, 2022, at 5:44 PM, Ray Andrews wrote:
> On 2022-10-27 13:02, Lawrence Velázquez wrote:
>> 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.

See zshexpn(1), in the paragraph immediately following the list of
glob qualifiers.  It is admittedly easy to overlook.

	More than one of these lists can be combined, separated by
	commas.  The whole list matches if at least one of the
	sublists matches (they are 'or'ed, the qualifiers in the
	sublists are 'and'ed).  Some qualifiers, however, affect
	all matches generated, independent of the sublist in which
	they are given.  These are the qualifiers 'M', 'T', 'N',
	'D', 'n', 'o', 'O' and the subscripts given in brackets
	('[...]').


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

By this definition, every possible command name is "actionable".
After all, *something* always 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.

A symlink is not inherently more "actionable" than a regular file
that does not have executable permissions.  The target is what's
important, not the symlink.

	% ln -s /bin/date link_a
	% ln -s /etc/passwd link_b
	% ./link_a
	Thu Oct 27 18:32:17 EDT 2022
	% ./link_b
	zsh: permission denied: ./link_b

As I said in my last message, the "-" glob qualifier allows you to
include or exclude symlinks based on their targets' attributes.
There is no reason to blindly lump all symlinks together, when you
can easily pick out the ones that actually matter.


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

No worries.


-- 
vq




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