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

Re: Compound Glob Specifiers



On Mon, Nov 8, 2021, at 6:03 PM, Zach Riggle wrote:
> *(/) is the glob specifier for directories [1]
>
> [...]
>
> [1] 
> https://zsh.sourceforge.io/Doc/Release/Expansion.html#index-BARE_005fGLOB_005fQUAL_002c-use-of

From that URL, except immediately above the anchor (emphasis mine):

    Patterns used for filename generation may *end* in a list of
    qualifiers enclosed in parentheses.

> It would then follow that *(/)/*(/)/somefile would match 
> dir/dir/somefile and not dir/link/somefile.
>
> This is not the case -- even *(/)/ (i.e. appending a trailing slash to 
> all directories) do not work out-of-the-box as one might expect.

Since your instances of (...) do not terminate your patterns, they
are interpreted as delimiters for grouping [*].  Another example:

    % touch /tmp/foo
    % print -r -- /*(p)/foo
    /tmp/foo

Clearly (p) is not acting as a glob qualifier here, as /tmp is not
a FIFO.  That pattern is equivalent to /*p/foo.

[*]: https://zsh.sourceforge.io/Doc/Release/Expansion.html#Glob-Operators

> I've read through 14.8 Filename Generation [2] as best I can (my 
> favorite hack being the NTREF=reffile bit) but haven't found anything 
> that suggests how one might do this.

I'll leave that for someone else, as I don't have any suggestions
at the moment.

-- 
vq




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