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

RE: Completion problems on cygwin when nocaseglob is set

I've finally built zsh 4.3.4 from the cygwin source package, and can
confirm the patch fixes the problem and I can now complete using

As an interesting note, I've also found that the slightly earlier zsh
4.3.2 (installed from cygwin's setup.exe) does not have the problem.
Completion works in this version (with setopt nocaseglob) through both
/c/ and c:/ . It even works after I delete my /c mount point directory
(c:\cygwin\c) even though "print /*" still does not include "/c".

    --- John.

-----Original Message-----
From: Peter Stephenson [mailto:pws@xxxxxxx] 
Sent: 23 October 2007 16:57
To: Zsh Users
Subject: Re: Completion problems on cygwin when nocaseglob is set

OK, I've found the underlying problem.  The cause is as discussed---"c"
doesn't appear in the directory listing for "/", which still strikes me
a bug.

I next noticed that "print /c/*" doesn't work.  The reason is that
couldn't find /c.  That #ifdef I pointed out before in pattern.c is
supposed to ensure that we don't do globbing on a directory just because
nocaseglob is in effect on Cygwin, since we'll find files with any case
without having to search.  However, it turns out there's another piece
code that's turning off the flag that says we've got a straight string
doesn't need globbing.  Using the same trick here allows us to pick up
without globbing to find it again.  c:/* now works again, too.

This means that /c*/* still doesn't find any files under /c, but this
I think it's a natural and unavoidable consequence of the fact that c
doesn't appear in the directory listing for /.

I haven't looked at fake-files.

Index: Src/pattern.c
RCS file: /cvsroot/zsh/zsh/Src/pattern.c,v
retrieving revision 1.40
diff -u -r1.40 pattern.c
--- Src/pattern.c	27 Jul 2007 21:51:33 -0000	1.40
+++ Src/pattern.c	23 Oct 2007 15:47:38 -0000
@@ -1167,7 +1167,26 @@
 	 * ..(#a1).. (i.e. the (#a1) has no effect), but if you're
 	 * going to write funny patterns, you get no sympathy from me.
-	if (patglobflags & (0xFF|GF_LCMATCHUC|GF_IGNCASE)) {
+	if (patglobflags &
+#ifdef __CYGWIN__
+	    /*
+	     * As above: don't use pattern matching for files
+	     * just because of case insensitivity if file system
+	     * is known to be case insensitive.
+	     *
+	     * This is known to be necessary in at least one case:
+	     * if "mount -c /" is in effect, so that drives appear
+	     * directly under / instead of the usual /cygdrive, they
+	     * aren't shown by readdir().  So it's vital we don't use
+	     * globbing to find "/c", since that'll fail.
+	     */
+	    ((patflags & PAT_FILE) ?
+	    (0xFF|GF_LCMATCHUC) :
+	    ) {
 	    if (!(patflags & PAT_FILE))
 		flags &= ~P_PURESTR;
 	    else if (!(nptr[0] == '.' &&

Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070

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