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

Re: glob qualifier '-' doesn't work correctly on dangling symlinks



On Sat, 2020-04-11 at 18:34 +0100, Stephane Chazelas wrote:
> 2020-04-11 17:15:11 +0200, Vincent Lefevre:
> [...]
> > +zsh:10> ls -l file3
> > lrwxrwxrwx 1 lefevre lefevre 5 2008-12-28 22:34:28 file3 -> file0
> > 
> > file*(-W) should have no matches.
> 
> [...]
> 
> It is not really documented but kind of implied that on broken
> symlinks, after -, we're still looking at the symlink instead of
> the target (there's no target for us to look at anyway).
> 
> The manual has:
> 
> >      ls -ld -- *(-@)
> > 
> > lists all broken symbolic links, and

Yes, it's already implicit and useful that this is how it works; I use
it myself.  We should document it better.  The current form is ambiguous
--- "the file it refers to" is meaningless if it doesn't refer to a
file.

We certainly can't change this at this stage, but that wouldn't stop us
adding something with alternative behaviour.

For convenience, the proposed wording in the attached is

item(tt(-))(
toggles between making the qualifiers work on symbolic links (the
default) and the files they point to, if any; a broken symbolic link
is treated as a file in its own right
)

pws
diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo
index 2a66ab997..fd1f1ca3b 100644
--- a/Doc/Zsh/expn.yo
+++ b/Doc/Zsh/expn.yo
@@ -2837,7 +2837,8 @@ negates all qualifiers following it
 )
 item(tt(-))(
 toggles between making the qualifiers work on symbolic links (the
-default) and the files they point to
+default) and the files they point to, if any; a broken symbolic link
+is treated as a file in its own right
 )
 item(tt(M))(
 sets the tt(MARK_DIRS) option for the current pattern


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