Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: glob qualifier '-' doesn't work correctly on dangling symlinks
On 2020-04-11 21:37:14 +0100, Stephane Chazelas wrote:
> 2020-04-11 21:17:11 +0200, Vincent Lefevre:
> [...]
> > > That's consistent with GNU find's -xtype l
> >
> > But the behavior is not consistent with the stat system call, with
> > the GNU stat utility (when using the --dereference option), and with
> > zsh/stat.
> [...]
>
> But ls/stat report information, and find/globs find files.
Globs find files based on reported information.
> find -xtype l and *(-@) are common, documented idioms. If only
> for that, I don't think the behaviour should be changed.
>
> And it's not clear what the better behaviour would be.
>
> If that broken link should not be matched by *(-W), should it be
> matched by *(-^W)? Why?
No, just like file0(^W) gives "zsh: no match" (as file0 does not exist).
> Or should that fail the glob (cause the shell process to exit)?
The shell process should not exit (except with "set -e").
The behavior should be: replace the link by the target, then
apply the glob qualifiers.
> What about for *(-e:code:)?
Since file0(e:foo:) does not make zsh execute foo, *(-e:code:) should
execute the code only on existing (and accessible) targets.
> Here, you can always work around the problem with *(-W^@).
But file3(-e:foo:^@) will execute "foo". That's not equivalent.
I suppose that the form *(-^@^W) is the generic way to do it.
However, currently, the behavior does not match the documentation.
--
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author