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

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 as
a bug.

I next noticed that "print /c/*" doesn't work.  The reason is that globbing
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 of
code that's turning off the flag that says we've got a straight string that
doesn't need globbing.  Using the same trick here allows us to pick up /c
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 time
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) :
+	    (0xFF|GF_LCMATCHUC|GF_IGNCASE))
+#else
+	    (0xFF|GF_LCMATCHUC|GF_IGNCASE)
+#endif
+	    ) {
 	    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