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

Re: Filename generation: instruct zsh not to follow symbolic links?



On Fri, Jul 17, 2026 at 1:36 AM Vincent Lefevre <vincent@xxxxxxxxxx> wrote:
>
> On 2026-07-16 18:04:54 +0200, Mikael Magnusson wrote:
> > On Thu, Jul 16, 2026 at 11:35 AM Vincent Lefevre <vincent@xxxxxxxxxx> wrote:
> > >
> > > On 2026-07-16 02:57:46 +0200, Mikael Magnusson wrote:
> > > > On Thu, Jul 16, 2026 at 1:47 AM Vincent Lefevre <vincent@xxxxxxxxxx> wrote:
> > > > >
> > > > > In filename generation, is there a way to instruct zsh not to follow
> > > > > symbolic links?
> > > > >
> > > > > Unfortunately, it is not possible to use glob qualifiers on
> > > > > pathname components (except the last one, i.e. ending the pattern),
> > > > > e.g. *(/)/foo, even though there would be no ambiguity in parsing
> > > > > (because a slash cannot appear in a pathname component).
> > > >
> > > > No, but you can do things like
> > > > () { mycmd $^@/foo } *(/)
> > > > which conveniently doesn't need any named temporary parameters.
> > >
> > > I get "No such file or directory" errors for some directories.
> > > But this is too complex anyway, and perhaps not usable in some
> > > situations.
> >
> > Right, you might need
> > () { setopt localoptions cshnullglob; mycmd $^@/foo } *(/)
> > :)
>
> I still get "No such file or directory" errors; or if I use "echo"
> as the command, I get non-existing files in the output.

It was implied that foo is a pattern in the above, in which case the
cshnullglob wil filter out the nonexistant ones.

> > > I would rather think that a (/ sequence could have a special meaning.
> > > That should be easy to parse.
> >
> > Sure, but that'd be an extreme special case then. You wouldn't be able
> > to use any other glob qualifiers there.
>
> Why not?

Because the other glob qualifiers are not '/' and hence will not match
the (/ sequence.

-- 
Mikael Magnusson




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