Re: Filename generation: instruct zsh not to follow symbolic links?
Mikael Magnusson <[email protected]> Fri, 17 Jul 2026 16:37:58 +0200
| Newsgroups | gmane.comp.shells.zsh.user |
|---|---|
| Message-ID | <CAHYJk3RGgObEZ__ugcwR7fvWnd40giw0Um_3D9_t=QkAjOtk=w@mail.gmail.com> |
On Fri, Jul 17, 2026 at 12:10=E2=80=AFPM Vincent Lefevre <[email protected]= t> wrote: > > On 2026-07-17 02:47:20 +0200, Mikael Magnusson wrote: > > On Fri, Jul 17, 2026 at 1:36=E2=80=AFAM Vincent Lefevre <vincent@vinc17= .net> wrote: > > > > > > On 2026-07-16 18:04:54 +0200, Mikael Magnusson wrote: > > > > On Thu, Jul 16, 2026 at 11:35=E2=80=AFAM Vincent Lefevre <vincent@v= inc17.net> wrote: > > > > > > > > > > On 2026-07-16 02:57:46 +0200, Mikael Magnusson wrote: > > > > > > On Thu, Jul 16, 2026 at 1:47=E2=80=AFAM Vincent Lefevre <vincen= [email protected]> 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 pat= tern), > > > > > > > e.g. *(/)/foo, even though there would be no ambiguity in par= sing > > > > > > > (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. > > In my case, "foo" is not a pattern. The goal was to get all the > files named "foo" in each subdirectory (which are not symlinks). In that case you can for example do this: () { setopt localoptions cshnullglob; mycmd $^@/foo(#q) } *(/) the #q does nothing here, except make the word a glob pattern. > > > > > I would rather think that a (/ sequence could have a special mean= ing. > > > > > That should be easy to parse. > > > > > > > > Sure, but that'd be an extreme special case then. You wouldn't be a= ble > > > > to use any other glob qualifiers there. > > > > > > Why not? > > > > Because the other glob qualifiers are not '/' and hence will not match > > the (/ sequence. > > This is not true: > > qaa% mkdir a b > qaa% chmod 500 b > qaa% ls -l > total 8 > drwxr-xr-x 2 vinc17 vinc17 4096 2026-07-17 11:35:03 a > dr-x------ 2 vinc17 vinc17 4096 2026-07-17 11:35:03 b > qaa% ls -ld *(/) > drwxr-xr-x 2 vinc17 vinc17 4096 2026-07-17 11:35:03 a > dr-x------ 2 vinc17 vinc17 4096 2026-07-17 11:35:03 b > qaa% ls -ld *(/w) > drwxr-xr-x 2 vinc17 vinc17 4096 2026-07-17 11:35:03 a 'w' is not a '/', so I'm not sure what this is supposed to demonstrate? How would you do the opposite of what you're currently trying to do, finding foo only in symlinked directories? (^/ and (@ both don't start with (/. --=20 Mikael Magnusson