zsh-users
 help / color / mirror / code / Atom feed
* Completion problems on cygwin when nocaseglob is set
@ 2007-10-20 11:41 John Cooper
  2007-10-20 12:09 ` Vin Shelton
  0 siblings, 1 reply; 23+ messages in thread
From: John Cooper @ 2007-10-20 11:41 UTC (permalink / raw)
  To: zsh-users; +Cc: John Cooper

I've just installed Vista and upgraded to zsh version 4.3.4 (from
cygwin).

If I `zsh -f', and then:
  $ setopt nocaseglob
  $ ls c:/<TAB>	# works - files in c:/ are listed

If I then:
  $ autoload -U compinit
  $ compinit
  $ ls c:/<TAB>   # fails - Windows beeps and no files are listed

If I then:
  $ setopt caseglob
  $ ls c:/<TAB>   # works again - files in c:/ are listed

This all used to work fine on my previous system - I can't recall the
zsh version although it was running on Win2K3.

I'd prefer to use nocaseglob. What would be the effect of removing the
call to compinit from my .zshrc? Interestingly, calling compinit doesn't
create a .zcompdump file, as the man-page suggests it should...

Thanks,

    --- John.


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Completion problems on cygwin when nocaseglob is set
  2007-10-20 11:41 Completion problems on cygwin when nocaseglob is set John Cooper
@ 2007-10-20 12:09 ` Vin Shelton
  2007-10-20 12:30   ` John Cooper
  0 siblings, 1 reply; 23+ messages in thread
From: Vin Shelton @ 2007-10-20 12:09 UTC (permalink / raw)
  To: John Cooper; +Cc: zsh-users

On 10/20/07, John Cooper wrote:
> I've just installed Vista and upgraded to zsh version 4.3.4 (from
> cygwin).
>
> If I `zsh -f', and then:
>   $ setopt nocaseglob
>   $ ls c:/<TAB> # works - files in c:/ are listed
>
> If I then:
>   $ autoload -U compinit
>   $ compinit
>   $ ls c:/<TAB>   # fails - Windows beeps and no files are listed
>
> If I then:
>   $ setopt caseglob
>   $ ls c:/<TAB>   # works again - files in c:/ are listed

Those are not valid filenames under cygwin.  You can use /cygdrive/c
(or /c if you mount c:/ there), but c:/ is not a posix-compatible
filename.  It may have worked in the past, but it was by accident, not
by design.  If you want more details, you can search the archives of
the cygwin mailing list.

HTH,
  Vin


-- 
The Journey by Mary Oliver
http://www.poemhunter.com/p/m/poem.asp?poet=6771&poem=30506


^ permalink raw reply	[flat|nested] 23+ messages in thread

* RE: Completion problems on cygwin when nocaseglob is set
  2007-10-20 12:09 ` Vin Shelton
@ 2007-10-20 12:30   ` John Cooper
  2007-10-22  9:34     ` Peter Stephenson
  0 siblings, 1 reply; 23+ messages in thread
From: John Cooper @ 2007-10-20 12:30 UTC (permalink / raw)
  To: Vin Shelton; +Cc: zsh-users

The file names are valid - perhaps I should have said that I've changed
the cygdrive prefix to "/" with `mount -c'.

Completion also fails if I use `cd /c/<TAB>' after I've `setopt
nocaseglob' and works if I `setopt caseglob'.

This looks to me to be a zsh bug that's been introduced in the last year
or so.

    --- John.

-----Original Message-----
From: ethersoft@gmail.com [mailto:ethersoft@gmail.com] On Behalf Of Vin
Shelton
Sent: 20 October 2007 13:09
To: John Cooper
Cc: zsh-users@sunsite.dk
Subject: Re: Completion problems on cygwin when nocaseglob is set

On 10/20/07, John Cooper wrote:
> I've just installed Vista and upgraded to zsh version 4.3.4 (from
> cygwin).
>
> If I `zsh -f', and then:
>   $ setopt nocaseglob
>   $ ls c:/<TAB> # works - files in c:/ are listed
>
> If I then:
>   $ autoload -U compinit
>   $ compinit
>   $ ls c:/<TAB>   # fails - Windows beeps and no files are listed
>
> If I then:
>   $ setopt caseglob
>   $ ls c:/<TAB>   # works again - files in c:/ are listed

Those are not valid filenames under cygwin.  You can use /cygdrive/c
(or /c if you mount c:/ there), but c:/ is not a posix-compatible
filename.  It may have worked in the past, but it was by accident, not
by design.  If you want more details, you can search the archives of
the cygwin mailing list.

HTH,
  Vin


-- 
The Journey by Mary Oliver
http://www.poemhunter.com/p/m/poem.asp?poet=6771&poem=30506


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Completion problems on cygwin when nocaseglob is set
  2007-10-20 12:30   ` John Cooper
@ 2007-10-22  9:34     ` Peter Stephenson
  2007-10-22 11:10       ` John Cooper
  0 siblings, 1 reply; 23+ messages in thread
From: Peter Stephenson @ 2007-10-22  9:34 UTC (permalink / raw)
  To: zsh-users

On Sat, 20 Oct 2007 13:30:02 +0100
"John Cooper" <john.cooper@eu.citrix.com> wrote:
> Completion also fails if I use `cd /c/<TAB>' after I've `setopt
> nocaseglob' and works if I `setopt caseglob'.

Are you saying all completion fails with "mount -c /" and "setopt nocaseglob"
regardless of anything else?  I can't get this to happen.  Is it specific
to this case, or does the usual "mount -c /cygdrive" show it too?  Is it
specific to absolute paths?  (In short, I'm likely to need a lot more
help.)

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


^ permalink raw reply	[flat|nested] 23+ messages in thread

* RE: Completion problems on cygwin when nocaseglob is set
  2007-10-22  9:34     ` Peter Stephenson
@ 2007-10-22 11:10       ` John Cooper
  2007-10-22 11:31         ` Peter Stephenson
  0 siblings, 1 reply; 23+ messages in thread
From: John Cooper @ 2007-10-22 11:10 UTC (permalink / raw)
  To: Peter Stephenson, zsh-users; +Cc: John Cooper

Completion fails with "mount -c /" and "setopt nocaseglob" and "autoload
-U compinit" and "autoload compinit".
It works with the more usual "mount -c /cygdrive".

If I start with the working "mount -c /cygdrive" I can repro the problem
as follows:

C:\>zsh -f
$P$Gmount
C:\cygwin\bin on /usr/bin type system (binmode)
C:\cygwin\lib on /usr/lib type system (binmode)
C:\cygwin on / type system (binmode)
b: on /cygdrive/b type system (binmode,noumount)
c: on /cygdrive/c type system (binmode,noumount)
d: on /cygdrive/d type system (binmode,noumount)
e: on /cygdrive/e type system (binmode,noumount)
r: on /cygdrive/r type system (binmode,noumount)
v: on /cygdrive/v type system (binmode,noumount)
$P$G
$P$Gsetopt nocaseglob
$P$Gautoload -U compinit
$P$Gcompinit
$P$G
$P$Gls /cygdrive/c/<TAB>       # this works
$P$G
$P$Gmount -c /
$P$G
$P$Gls /c/<TAB>                # this fails


At this stage "ls /c" lists the files in c:\, but completion fails when
I "ls /c/<TAB>".
The problem seems specific to absolute paths. If I "cd /c" I can then
complete files and folders relative to "/c".


My mount table is now as follows:

$P$Gmount
C:\cygwin\bin on /usr/bin type system (binmode)
C:\cygwin\lib on /usr/lib type system (binmode)
C:\cygwin on / type system (binmode)
b: on /b type system (binmode,noumount)
c: on /c type system (binmode,noumount)
d: on /d type system (binmode,noumount)
e: on /e type system (binmode,noumount)
r: on /r type system (binmode,noumount)
v: on /v type system (binmode,noumount)

Thanks,

    --- John.

-----Original Message-----
From: Peter Stephenson [mailto:pws@csr.com] 
Sent: 22 October 2007 10:35
To: zsh-users@sunsite.dk
Subject: Re: Completion problems on cygwin when nocaseglob is set

On Sat, 20 Oct 2007 13:30:02 +0100
"John Cooper" <john.cooper@eu.citrix.com> wrote:
> Completion also fails if I use `cd /c/<TAB>' after I've `setopt
> nocaseglob' and works if I `setopt caseglob'.

Are you saying all completion fails with "mount -c /" and "setopt
nocaseglob"
regardless of anything else?  I can't get this to happen.  Is it
specific
to this case, or does the usual "mount -c /cygdrive" show it too?  Is it
specific to absolute paths?  (In short, I'm likely to need a lot more
help.)

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


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Completion problems on cygwin when nocaseglob is set
  2007-10-22 11:10       ` John Cooper
@ 2007-10-22 11:31         ` Peter Stephenson
  2007-10-22 13:13           ` John Cooper
  0 siblings, 1 reply; 23+ messages in thread
From: Peter Stephenson @ 2007-10-22 11:31 UTC (permalink / raw)
  To: Zsh Users

On Mon, 22 Oct 2007 12:10:04 +0100
"John Cooper" <John.Cooper@citrix.com> wrote:
> Completion fails with "mount -c /" and "setopt nocaseglob" and "autoload
> -U compinit" and "autoload compinit".
> It works with the more usual "mount -c /cygdrive".

I still can't get this to happen.  Do you have MULTIBYTE_SUPPORT in
config.h?  Does the following patch (which shouldn't be necessary in any
case) make any difference?  Could you send the output of ^x?
(_complete_debug) in the failing case?

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	22 Oct 2007 11:26:36 -0000
@@ -512,7 +512,7 @@
     if (!(patflags & PAT_ANY)) {
 	/* Look for a really pure string, with no tokens at all. */
 	if (!patglobflags
-#ifdef __CYGWIN__
+#if 0 /* def __CYGWIN__ */
 	    /*
 	     * If the OS treats files case-insensitively and we
 	     * are looking at files, we don't need to use pattern

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


^ permalink raw reply	[flat|nested] 23+ messages in thread

* RE: Completion problems on cygwin when nocaseglob is set
  2007-10-22 11:31         ` Peter Stephenson
@ 2007-10-22 13:13           ` John Cooper
  2007-10-23  9:11             ` Peter Stephenson
  0 siblings, 1 reply; 23+ messages in thread
From: John Cooper @ 2007-10-22 13:13 UTC (permalink / raw)
  To: Peter Stephenson, Zsh Users; +Cc: John Cooper

[-- Attachment #1: Type: text/plain, Size: 1859 bytes --]

I've attached the output from ^x? in the failing case.

I installed zsh (4.3.4) via cygwin's setup.exe program towards the end
of last week. I'm using Windows Vista - not sure if that might be
contributing to the problem?

MULTIBYTE_SUPPORT is not defined in either /usr/include/cygwin/config.h
or /usr/include/sys/config.h.

    --- John.


-----Original Message-----
From: Peter Stephenson [mailto:pws@csr.com] 
Sent: 22 October 2007 12:31
To: Zsh Users
Subject: Re: Completion problems on cygwin when nocaseglob is set

On Mon, 22 Oct 2007 12:10:04 +0100
"John Cooper" <John.Cooper@citrix.com> wrote:
> Completion fails with "mount -c /" and "setopt nocaseglob" and
"autoload
> -U compinit" and "autoload compinit".
> It works with the more usual "mount -c /cygdrive".

I still can't get this to happen.  Do you have MULTIBYTE_SUPPORT in
config.h?  Does the following patch (which shouldn't be necessary in any
case) make any difference?  Could you send the output of ^x?
(_complete_debug) in the failing case?

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	22 Oct 2007 11:26:36 -0000
@@ -512,7 +512,7 @@
     if (!(patflags & PAT_ANY)) {
 	/* Look for a really pure string, with no tokens at all. */
 	if (!patglobflags
-#ifdef __CYGWIN__
+#if 0 /* def __CYGWIN__ */
 	    /*
 	     * If the OS treats files case-insensitively and we
 	     * are looking at files, we don't need to use pattern

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

[-- Attachment #2: zsh4540ls1 --]
[-- Type: application/octet-stream, Size: 48110 bytes --]

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Completion problems on cygwin when nocaseglob is set
  2007-10-22 13:13           ` John Cooper
@ 2007-10-23  9:11             ` Peter Stephenson
  2007-10-23 11:11               ` John Cooper
  0 siblings, 1 reply; 23+ messages in thread
From: Peter Stephenson @ 2007-10-23  9:11 UTC (permalink / raw)
  To: Zsh Users

On Mon, 22 Oct 2007 14:13:38 +0100
"John Cooper" <John.Cooper@citrix.com> wrote:
> I've attached the output from ^x? in the failing case.

I think the problem is somewhere in the utility compfiles.  Given a path /
and a PREFIX c it should come up with a list of files at least including
"c", but it doesn't.  compfiles is incredibly obscure, but somewhere in
there it's doing globbing.

Does "print /*"  show everything you would expect?

Does setting
  zstyle ':completion:*' fake-files '/:c'
work around the problem?

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


^ permalink raw reply	[flat|nested] 23+ messages in thread

* RE: Completion problems on cygwin when nocaseglob is set
  2007-10-23  9:11             ` Peter Stephenson
@ 2007-10-23 11:11               ` John Cooper
  2007-10-23 11:56                 ` Peter Stephenson
  0 siblings, 1 reply; 23+ messages in thread
From: John Cooper @ 2007-10-23 11:11 UTC (permalink / raw)
  To: Peter Stephenson, Zsh Users; +Cc: John Cooper

Setting the fake-files zstyle doesn't help.

"print /*" does not include "/c" after I "mount -c /" (I don't know
whether it should?). 
If I "mount -c /cygdrive" then "print /*" includes "/cygdrive" (and
completion works), and "print /cygdrive/*" lists all my mounted drives.
If I "mount -c /m" then "print /*" includes "/m" (and completion works).

It's only when I "mount -c /" that the problem occurs.

However, with zsh 4.2.6 (and an earlier version of cygwin) on WinXP,
"print /*" also does not include "/c", but completion works here.

    --- John.


-----Original Message-----
From: Peter Stephenson [mailto:pws@csr.com] 
Sent: 23 October 2007 10:12
To: Zsh Users
Subject: Re: Completion problems on cygwin when nocaseglob is set

On Mon, 22 Oct 2007 14:13:38 +0100
"John Cooper" <John.Cooper@citrix.com> wrote:
> I've attached the output from ^x? in the failing case.

I think the problem is somewhere in the utility compfiles.  Given a path
/
and a PREFIX c it should come up with a list of files at least including
"c", but it doesn't.  compfiles is incredibly obscure, but somewhere in
there it's doing globbing.

Does "print /*"  show everything you would expect?

Does setting
  zstyle ':completion:*' fake-files '/:c'
work around the problem?

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


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Completion problems on cygwin when nocaseglob is set
  2007-10-23 11:11               ` John Cooper
@ 2007-10-23 11:56                 ` Peter Stephenson
  2007-10-23 14:04                   ` John Cooper
  0 siblings, 1 reply; 23+ messages in thread
From: Peter Stephenson @ 2007-10-23 11:56 UTC (permalink / raw)
  To: Zsh Users

"John Cooper" wrote:
> Setting the fake-files zstyle doesn't help.

That's very strange, since that's got nothing to do with Cygwin and it
does work elsewhere.  But I can see that too, and I can see that
fake-files does produce files that actually aren't there (e.g. if I use
"/:a b c" I get a and b).  However, unfortunately the setting in question
disappears into the horrors of compfiles.  This looks like a bug that
may or may not be associated with the other problems.

> "print /*" does not include "/c" after I "mount -c /" (I don't know
> whether it should?).

This is likely to be the cause of why this case is different (even if
the shell is doing something a bit weird, too).  If globbing can't see
it compfiles won't.  What's more, with this knowledge I can reproduce
your problem: I had a directory /c that I was using for mount c:
directly and with "cygpath -c /" this was appearing for globbing an the
completion system.  This gives a workaround, at least: "mkdir /c".

I can't see why /c wouldn't appear to globbing, but it doesn't in bash
either so presumably readdir() doesn't return it.  This is a question
for the Cygwin people.  Since, as you say

> If I "mount -c /cygdrive" then "print /*" includes "/cygdrive" (and
> completion works), and "print /cygdrive/*" lists all my mounted drives.

this looks to me like a bug, or at the least a limitation of overlaying
the drives on an existing directory.

> However, with zsh 4.2.6 (and an earlier version of cygwin) on WinXP,
> "print /*" also does not include "/c", but completion works here.

I've no idea why this would be different.  None of the changes I can see
in compfiles look like they would make a difference.  It ought to be
possible (even easy, if you know how to do it) to add a special case so
that a statable file is always added as a match.  However, maybe it should
be doing that anyway.  If anybody understood compfiles they might be
able to answer this.  I hesitate to do this without more thought.

It would help if I could debug this on a native Unix operating system.

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


^ permalink raw reply	[flat|nested] 23+ messages in thread

* RE: Completion problems on cygwin when nocaseglob is set
  2007-10-23 11:56                 ` Peter Stephenson
@ 2007-10-23 14:04                   ` John Cooper
  2007-10-23 15:57                     ` Peter Stephenson
  0 siblings, 1 reply; 23+ messages in thread
From: John Cooper @ 2007-10-23 14:04 UTC (permalink / raw)
  To: Peter Stephenson, Zsh Users; +Cc: John Cooper

Excellent - I can confirm "mkdir /c" does provide a workaround, and "ls
/c/<TAB>" now works.

However, with "setopt nocaseglob", I can no longer complete using "ls
c:/<TAB>" regardless of whether I "mount -c /" or "mount -c /cygdrive".
If I "setopt caseglob", I can then complete using "ls c:/<TAB>". This
again also used to work fine with "setopt nocaseglob" in zsh 4.2.6 (with
earlier cygwin library) on WinXP.

I've tried setting the following but they don't help:
$ zstyle 
fake-files
        :completion:* /:c /:d /:b /:o /:w /:r /:v
accept-exact
        :completion:*:paths c: d: b: o: w: r: v:


Btw, thanks very much for all the time you've spent looking into this.

    --- John.

-----Original Message-----
From: Peter Stephenson [mailto:pws@csr.com] 
Sent: 23 October 2007 12:56
To: Zsh Users
Subject: Re: Completion problems on cygwin when nocaseglob is set

"John Cooper" wrote:
> Setting the fake-files zstyle doesn't help.

That's very strange, since that's got nothing to do with Cygwin and it
does work elsewhere.  But I can see that too, and I can see that
fake-files does produce files that actually aren't there (e.g. if I use
"/:a b c" I get a and b).  However, unfortunately the setting in
question
disappears into the horrors of compfiles.  This looks like a bug that
may or may not be associated with the other problems.

> "print /*" does not include "/c" after I "mount -c /" (I don't know
> whether it should?).

This is likely to be the cause of why this case is different (even if
the shell is doing something a bit weird, too).  If globbing can't see
it compfiles won't.  What's more, with this knowledge I can reproduce
your problem: I had a directory /c that I was using for mount c:
directly and with "cygpath -c /" this was appearing for globbing an the
completion system.  This gives a workaround, at least: "mkdir /c".

I can't see why /c wouldn't appear to globbing, but it doesn't in bash
either so presumably readdir() doesn't return it.  This is a question
for the Cygwin people.  Since, as you say

> If I "mount -c /cygdrive" then "print /*" includes "/cygdrive" (and
> completion works), and "print /cygdrive/*" lists all my mounted
drives.

this looks to me like a bug, or at the least a limitation of overlaying
the drives on an existing directory.

> However, with zsh 4.2.6 (and an earlier version of cygwin) on WinXP,
> "print /*" also does not include "/c", but completion works here.

I've no idea why this would be different.  None of the changes I can see
in compfiles look like they would make a difference.  It ought to be
possible (even easy, if you know how to do it) to add a special case so
that a statable file is always added as a match.  However, maybe it
should
be doing that anyway.  If anybody understood compfiles they might be
able to answer this.  I hesitate to do this without more thought.

It would help if I could debug this on a native Unix operating system.

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


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Completion problems on cygwin when nocaseglob is set
  2007-10-23 14:04                   ` John Cooper
@ 2007-10-23 15:57                     ` Peter Stephenson
  2007-10-23 17:12                       ` Wayne Davison
  2007-10-24 12:45                       ` John Cooper
  0 siblings, 2 replies; 23+ messages in thread
From: Peter Stephenson @ 2007-10-23 15:57 UTC (permalink / raw)
  To: Zsh Users

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@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Completion problems on cygwin when nocaseglob is set
  2007-10-23 15:57                     ` Peter Stephenson
@ 2007-10-23 17:12                       ` Wayne Davison
  2007-10-23 17:24                         ` Peter Stephenson
  2007-10-24 12:45                       ` John Cooper
  1 sibling, 1 reply; 23+ messages in thread
From: Wayne Davison @ 2007-10-23 17:12 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: Zsh Users

On Tue, Oct 23, 2007 at 04:57:08PM +0100, Peter Stephenson wrote:
> 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.

Perhaps you didn't mkdir /c before using the mount command?  e.g.,
see this thread:

http://www.cygwin.com/ml/cygwin/2003-07/msg01188.html

..wayne..


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Completion problems on cygwin when nocaseglob is set
  2007-10-23 17:12                       ` Wayne Davison
@ 2007-10-23 17:24                         ` Peter Stephenson
  2007-10-23 17:40                           ` Peter Stephenson
  2007-10-23 17:45                           ` Wayne Davison
  0 siblings, 2 replies; 23+ messages in thread
From: Peter Stephenson @ 2007-10-23 17:24 UTC (permalink / raw)
  To: Zsh Users

Wayne Davison wrote:
> On Tue, Oct 23, 2007 at 04:57:08PM +0100, Peter Stephenson wrote:
> > 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.
> 
> Perhaps you didn't mkdir /c before using the mount command? 

We didn't (at least, John didn't), and shouldn't need to; that's the
bug.  The cygdrive directory should automatically put the files into a
listing via readdir() whenever they're visible by a direct opendir().

> e.g., see this thread:
> 
> http://www.cygwin.com/ml/cygwin/2003-07/msg01188.html

Yes, that seems to be the same conclusion as us:  "mount -c /" fails in
that way and no one really knows why.

pws


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Completion problems on cygwin when nocaseglob is set
  2007-10-23 17:24                         ` Peter Stephenson
@ 2007-10-23 17:40                           ` Peter Stephenson
  2007-10-23 17:56                             ` Peter A. Castro
  2007-10-23 17:45                           ` Wayne Davison
  1 sibling, 1 reply; 23+ messages in thread
From: Peter Stephenson @ 2007-10-23 17:40 UTC (permalink / raw)
  To: Zsh Users

On Tue, 23 Oct 2007 18:24:22 +0100
Peter Stephenson <pws@csr.com> wrote:
> > http://www.cygwin.com/ml/cygwin/2003-07/msg01188.html
> 
> Yes, that seems to be the same conclusion as us:  "mount -c /" fails in
> that way and no one really knows why.

Actually, now I've actually bothered looking, that's a different
failure.  In that case, "ls /c" didn't work, but we didn't have that problem
even if /c wasn't explicitly created.  Our problem (with Cygwin) is that "ls /"
doesn't list "c", even though "/c" when directly addressed behaves normally.

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


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Completion problems on cygwin when nocaseglob is set
  2007-10-23 17:24                         ` Peter Stephenson
  2007-10-23 17:40                           ` Peter Stephenson
@ 2007-10-23 17:45                           ` Wayne Davison
  2007-10-23 17:53                             ` John Cooper
  1 sibling, 1 reply; 23+ messages in thread
From: Wayne Davison @ 2007-10-23 17:45 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: Zsh Users

On Tue, Oct 23, 2007 at 06:24:22PM +0100, Peter Stephenson wrote:
> We didn't (at least, John didn't), and shouldn't need to; that's the
> bug.

I think the bug is the opposite:  the mount should fail unless the dirs
already exist.

..wayne..


^ permalink raw reply	[flat|nested] 23+ messages in thread

* RE: Completion problems on cygwin when nocaseglob is set
  2007-10-23 17:45                           ` Wayne Davison
@ 2007-10-23 17:53                             ` John Cooper
  0 siblings, 0 replies; 23+ messages in thread
From: John Cooper @ 2007-10-23 17:53 UTC (permalink / raw)
  To: Wayne Davison, Peter Stephenson; +Cc: Zsh Users

By default drives are mounted on /cygdrive, but the cygwin environment
doesn't create this directory. Do you think that's a bug too?

    --- John.

-----Original Message-----
From: Wayne Davison [mailto:wayned@users.sourceforge.net] 
Sent: 23 October 2007 18:45
To: Peter Stephenson
Cc: Zsh Users
Subject: Re: Completion problems on cygwin when nocaseglob is set

On Tue, Oct 23, 2007 at 06:24:22PM +0100, Peter Stephenson wrote:
> We didn't (at least, John didn't), and shouldn't need to; that's the
> bug.

I think the bug is the opposite:  the mount should fail unless the dirs
already exist.

..wayne..


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Completion problems on cygwin when nocaseglob is set
  2007-10-23 17:40                           ` Peter Stephenson
@ 2007-10-23 17:56                             ` Peter A. Castro
  2007-10-23 19:48                               ` Peter Stephenson
  0 siblings, 1 reply; 23+ messages in thread
From: Peter A. Castro @ 2007-10-23 17:56 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: Zsh Users

On Tue, 23 Oct 2007, Peter Stephenson wrote:

Greetings, Peter & John,

> On Tue, 23 Oct 2007 18:24:22 +0100
> Peter Stephenson <pws@csr.com> wrote:
>>> http://www.cygwin.com/ml/cygwin/2003-07/msg01188.html
>>
>> Yes, that seems to be the same conclusion as us:  "mount -c /" fails in
>> that way and no one really knows why.
>
> Actually, now I've actually bothered looking, that's a different
> failure.  In that case, "ls /c" didn't work, but we didn't have that problem
> even if /c wasn't explicitly created.  Our problem (with Cygwin) is that "ls /"
> doesn't list "c", even though "/c" when directly addressed behaves normally.

"ls /c" won't list "c" unless that dir exists on the underlying
filesystem of the mount point.  That's more a of a Cygwin and Windows
thing than a zsh thing.  Obviously if readdir() isn't returning the entry
it can't be zsh's fault.

Remember that Cygwin is a simulated filesystem on top of the real
filesystem, so certain things defer to the real backing store, for
content, and this appears to be one of those cases.

Likewise doing "ls /c/<tab>" won't work because "c" doesn't exist in the
mount point's dir and can't be looked up for a dir list.

Now, as to the caseglob'ing working in 4.2.6 and not 4.3.4...well, there
have been several changes in the completion system between those two
versions.

PeterS, is it time for a new release? A lot of fixes have been committed
since 4.3.4...

-- 
Peter A. Castro <doctor@fruitbat.org> or <Peter.Castro@oracle.com>
 	"Cats are just autistic Dogs" -- Dr. Tony Attwood


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Completion problems on cygwin when nocaseglob is set
  2007-10-23 17:56                             ` Peter A. Castro
@ 2007-10-23 19:48                               ` Peter Stephenson
  0 siblings, 0 replies; 23+ messages in thread
From: Peter Stephenson @ 2007-10-23 19:48 UTC (permalink / raw)
  To: Zsh Users

"Peter A. Castro" wrote:
> Likewise doing "ls /c/<tab>" won't work because "c" doesn't exist in the
> mount point's dir and can't be looked up for a dir list.

Ideally this should work if "/c" itself is readable, whether or not
listing "/" shows it; this was the problem in zsh I've fixed.

> PeterS, is it time for a new release? A lot of fixes have been committed
> since 4.3.4...

Yes, it is.  We should make zcurses fairly stable, though not
necessarily complete (I keep forgetting my patch for non-ncurses
compilation), but the rest is probably OK for now.

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


^ permalink raw reply	[flat|nested] 23+ messages in thread

* RE: Completion problems on cygwin when nocaseglob is set
  2007-10-23 15:57                     ` Peter Stephenson
  2007-10-23 17:12                       ` Wayne Davison
@ 2007-10-24 12:45                       ` John Cooper
  2007-10-24 14:01                         ` Vin Shelton
  1 sibling, 1 reply; 23+ messages in thread
From: John Cooper @ 2007-10-24 12:45 UTC (permalink / raw)
  To: Peter Stephenson, Zsh Users

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
c:/<TAB>.

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@csr.com] 
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
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@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Completion problems on cygwin when nocaseglob is set
  2007-10-24 12:45                       ` John Cooper
@ 2007-10-24 14:01                         ` Vin Shelton
  2007-10-24 15:09                           ` Peter Stephenson
  0 siblings, 1 reply; 23+ messages in thread
From: Vin Shelton @ 2007-10-24 14:01 UTC (permalink / raw)
  To: John Cooper; +Cc: Peter Stephenson, Zsh Users

I'm very confused.  Running zsh built from the latest CVS sources,
here's what I see:

zsh -f
$ mount -p
Prefix              Type         Flags
/                   system       binmode
$ cd /c
$ ls -dF [dD]*
Documents and Settings/  dell/  dell.sdr*
$ cd d<TAB>

    completes to dell. This is correct so far.

$ setopt nocaseglob
$ ls -dF d*
Documents and Settings/  dell/  dell.sdr*

    Correct again.

$ cd d<TAB>
    again completes to dell.  Shouldn't this give me a choice between:
    dell and Documents\ and\ Settings ?

Similarly,
$ ls a*
AUTOEXEC.BAT
$ ls a<TAB>
    just beeps at me.

and finally,
$ autoload compinit
$ compinit
    has no effect, i.e.
$ ls a<TAB>
    still just beeps at me.

Before John started asking questions about case-insensitive
completion, I hadn't noticed this behavior because I have been using
this workaround:

zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'

but isn't setopt nocaseglob meant to obviate the need for that?

Regards,
  Vin


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Completion problems on cygwin when nocaseglob is set
  2007-10-24 14:01                         ` Vin Shelton
@ 2007-10-24 15:09                           ` Peter Stephenson
  2007-10-24 20:37                             ` Vin Shelton
  0 siblings, 1 reply; 23+ messages in thread
From: Peter Stephenson @ 2007-10-24 15:09 UTC (permalink / raw)
  To: Zsh Users

"Vin Shelton" wrote:
> I'm very confused.  Running zsh built from the latest CVS sources,
> here's what I see:

... even with NO_CASE_GLOB set, completion doesn't match
case-insensitively unless there's a matcher spec to do it.

Oh dear, I hate it when people are confused about completion because
that invariably means a hard time.

It looks like _path_files is doing the right thing internally (via
compfiles, which understands glob settings), but it then passes the
matched string to compadd without the -U flag, which says "sorry mate,
it's more than my job's worth to match case-insensitively".  _path_files
does most of its file handling itself or via compfiles, but it doesn't
do the special matching stuff, hence we can't pass -U in that case.

We could make a rule that we use case-insensitive matching with
NO_CASE_GLOB unless an explicit matcher spec is in force, I suppose, but
we can't actually have the combined effect of nocaseglob and matchers
without either some kind of internal rewrite, or editing the matchers
passed down through _path_files.  If the former is acceptable, this is
fairly straightforward.

Index: Completion/Unix/Type/_path_files
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_path_files,v
retrieving revision 1.25
diff -u -r1.25 _path_files
--- Completion/Unix/Type/_path_files	7 Mar 2006 12:52:27 -0000	1.25
+++ Completion/Unix/Type/_path_files	24 Oct 2007 15:08:14 -0000
@@ -101,7 +101,16 @@
   (( $mopts[(I)-F] )) || mopts=( "$mopts[@]" -F _comp_ignore )
 fi
 
-(( $#matcher )) && mopts=( "$mopts[@]" "$matcher[@]" )
+if [[ $#matcher -eq 0 && -o nocaseglob ]]; then
+  # If globbing is case insensitive and there's no matcher,
+  # do case-insensitive matching.
+  matcher=( -M 'm:{a-zA-Z}={A-Za-z}' )
+fi
+
+if (( $#matcher )); then
+  # Add the current matcher to the options to compadd.
+  mopts=( "$mopts[@]" "$matcher[@]" )
+fi
 
 if zstyle -s ":completion:${curcontext}:" file-sort tmp1; then
   case "$tmp1" in
Index: Doc/Zsh/compsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.202
diff -u -r1.202 compsys.yo
--- Doc/Zsh/compsys.yo	19 Jun 2007 09:28:06 -0000	1.202
+++ Doc/Zsh/compsys.yo	24 Oct 2007 15:08:22 -0000
@@ -1968,6 +1968,11 @@
 one to three strings will give acceptable performance.  On the other
 hand, putting multiple space-separated values into the same string does
 not have an appreciable impact on performance.
+
+If there is no current matcher or it is empty, and the option
+tt(NO_CASE_GLOB) is in effect, the matching for files is performed
+case-insensitively in any case.  However, any matcher must
+explicitly specify case-insensitive matching if that is required.
 )
 kindex(max-errors, completion style)
 item(tt(max-errors))(

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


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Completion problems on cygwin when nocaseglob is set
  2007-10-24 15:09                           ` Peter Stephenson
@ 2007-10-24 20:37                             ` Vin Shelton
  0 siblings, 0 replies; 23+ messages in thread
From: Vin Shelton @ 2007-10-24 20:37 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: Zsh Users

On 10/24/07, Peter Stephenson <pws@csr.com> wrote:
> "Vin Shelton" wrote:
> > I'm very confused.  Running zsh built from the latest CVS sources,
> > here's what I see:
>
> ... even with NO_CASE_GLOB set, completion doesn't match
> case-insensitively unless there's a matcher spec to do it.
>
> Oh dear, I hate it when people are confused about completion because
> that invariably means a hard time.

Thanks for explaining this Peter.  As a naive end-user I forget the
complexities of the inter-relationships of the parts.  Ideally (IMO),
'setopt nocaseglob' should work for both globbing and completion.

>
> It looks like _path_files is doing the right thing internally (via
> compfiles, which understands glob settings), but it then passes the
> matched string to compadd without the -U flag, which says "sorry mate,
> it's more than my job's worth to match case-insensitively".  _path_files
> does most of its file handling itself or via compfiles, but it doesn't
> do the special matching stuff, hence we can't pass -U in that case.
>
> We could make a rule that we use case-insensitive matching with
> NO_CASE_GLOB unless an explicit matcher spec is in force, I suppose, but
> we can't actually have the combined effect of nocaseglob and matchers
> without either some kind of internal rewrite, or editing the matchers
> passed down through _path_files.  If the former is acceptable, this is
> fairly straightforward.

If by 'former' you meant that NO_CASE_GLOB works if no explicit
matcher is specified (which looks like what you implemented below),
then I agree.

I applied the patch and verified that my naive test case now works.

Thank you,
  Vin


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2007-10-24 20:38 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-20 11:41 Completion problems on cygwin when nocaseglob is set John Cooper
2007-10-20 12:09 ` Vin Shelton
2007-10-20 12:30   ` John Cooper
2007-10-22  9:34     ` Peter Stephenson
2007-10-22 11:10       ` John Cooper
2007-10-22 11:31         ` Peter Stephenson
2007-10-22 13:13           ` John Cooper
2007-10-23  9:11             ` Peter Stephenson
2007-10-23 11:11               ` John Cooper
2007-10-23 11:56                 ` Peter Stephenson
2007-10-23 14:04                   ` John Cooper
2007-10-23 15:57                     ` Peter Stephenson
2007-10-23 17:12                       ` Wayne Davison
2007-10-23 17:24                         ` Peter Stephenson
2007-10-23 17:40                           ` Peter Stephenson
2007-10-23 17:56                             ` Peter A. Castro
2007-10-23 19:48                               ` Peter Stephenson
2007-10-23 17:45                           ` Wayne Davison
2007-10-23 17:53                             ` John Cooper
2007-10-24 12:45                       ` John Cooper
2007-10-24 14:01                         ` Vin Shelton
2007-10-24 15:09                           ` Peter Stephenson
2007-10-24 20:37                             ` Vin Shelton

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).