zsh-workers
 help / color / mirror / code / Atom feed
* Re: PATCH: case-insensitive globbing
       [not found] <18393.1078742029@csr.com>
@ 2004-03-08 12:03 ` Peter Stephenson
  2004-03-08 13:38   ` Oliver Kiddle
  0 siblings, 1 reply; 8+ messages in thread
From: Peter Stephenson @ 2004-03-08 12:03 UTC (permalink / raw)
  To: Zsh hackers list

Peter Stephenson wrote:
> There's one patch I need to get in to improve efficiency on Cygwin
> (currently the shell will try to search the entire directory for files
> since it doesn't know the OS treats all files case insensitively)
> which I'll try and do later.

This is it.  Seems to work OK, but could do with some playing around
with by a Cygwin hacker.

Oliver wrote:
> It's just a thought but would it be somehow possible to detect the
> filesystem type and allow the efficency gain to be of use where, for
> example, a windows partition is mounted from linux.

Yes, it occurred to me, but it's too complicated for now.  Also, it
means checking for every single file when the option is on.  I'm not
sure this can be done efficiently.


Index: Src/pattern.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/pattern.c,v
retrieving revision 1.17
diff -u -r1.17 pattern.c
--- Src/pattern.c	6 Mar 2004 00:23:03 -0000	1.17
+++ Src/pattern.c	8 Mar 2004 11:49:37 -0000
@@ -344,7 +344,16 @@
 
     if (!(patflags & PAT_ANY)) {
 	/* Look for a really pure string, with no tokens at all. */
-	if (!patglobflags)
+	if (!patglobflags
+#ifdef __CYGWIN__
+	    /*
+	     * If the OS treats files case-insensitively and we
+	     * are looking at files, we don't need to use pattern
+	     * matching to find the file.
+	     */
+	    || (!(patglobflags & ~GF_IGNCASE) && (patflags & PAT_FILE))
+#endif
+	    )
 	    for (strp = exp; *strp &&
 		     (!(patflags & PAT_FILE) || *strp != '/') && !itok(*strp);
 		 strp++)

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


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

* Re: PATCH: case-insensitive globbing
  2004-03-08 12:03 ` PATCH: case-insensitive globbing Peter Stephenson
@ 2004-03-08 13:38   ` Oliver Kiddle
  2004-03-08 13:45     ` Peter Stephenson
  0 siblings, 1 reply; 8+ messages in thread
From: Oliver Kiddle @ 2004-03-08 13:38 UTC (permalink / raw)
  To: Zsh hackers list; +Cc: James Devenish

Peter wrote:
> 
> > It's just a thought but would it be somehow possible to detect the
> > filesystem type and allow the efficency gain to be of use where, for
> > example, a windows partition is mounted from linux.
> 
> Yes, it occurred to me, but it's too complicated for now.  Also, it
> means checking for every single file when the option is on.  I'm not
> sure this can be done efficiently.

Wouldn't each directory be sufficient?

> +	if (!patglobflags
> +#ifdef __CYGWIN__

As pointed out by James Devenish, it is probably also relevant for Mac
OS X. Can anyone confirm what preprocessor defines we should be looking
for? My reading of this:
  http://developer.apple.com/technotes/tn2002/tn2071.html
would indicate both __APPLE__ and __MACH__ but it isn't entirely clear.

Oliver


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

* Re: PATCH: case-insensitive globbing
  2004-03-08 13:38   ` Oliver Kiddle
@ 2004-03-08 13:45     ` Peter Stephenson
  0 siblings, 0 replies; 8+ messages in thread
From: Peter Stephenson @ 2004-03-08 13:45 UTC (permalink / raw)
  To: Zsh hackers list

Oliver Kiddle wrote:
> As pointed out by James Devenish, it is probably also relevant for Mac
> OS X.

It doesn't look like there's a global test, it depends on the file
system.  I definitely do not want to try to incorporate a per-directory
test into 4.2.0 at the last minute; it can wait.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


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

* Re: PATCH: case-insensitive globbing
  2004-03-08 13:49     ` James Devenish
@ 2004-03-08 16:36       ` Peter Stephenson
  0 siblings, 0 replies; 8+ messages in thread
From: Peter Stephenson @ 2004-03-08 16:36 UTC (permalink / raw)
  To: James Devenish, Zsh hackers list

James Devenish wrote:
> In message <20040308124027.GA15505@mail.guild.uwa.edu.au>
> on Mon, Mar 08, 2004 at 08:40:27PM +0800, James Devenish wrote:
> > In message <5792.1078749261@csr.com>
> > on Mon, Mar 08, 2004 at 12:34:21PM +0000, Peter Stephenson wrote:
> > > > % ls /tmp/blah
> > > > DATE
> > > > % rehash
> > > > % where date
> > > > /tmp/blah/date
> > > > /bin/date
> 
> But, now I note:
> 
> % where DATE
> /tmp/blah/DATE
> /bin/DATE
> 
> So...fair enough. An odd experience, but does make sense. For all I
> know, this might even be an Apply kludge to make ported POSIX software
> work in a case-insensitive environment (I haven't looked at how zsh
> queries the OS for these files). [BTW: I received your reply after I
> had already written this e-mail.] On a related note:
> 
> % ls -l =date
> -r-xr-xr-x  1 root  wheel  19276 24 Sep 14:51 /bin/date*
> % ls -l =DATE
> -r-xr-xr-x  1 admin  wheel  19276 24 Sep 14:51 /tmp/blah/DATE*
> 
> Not complaining about this -- just pointing it out so that everyone's
> aware of it. I don't know how this and other such letter-case issues are
> handled in Cygwin. Perhaps there could be a footnote to the caseglob

The difference is that `where' is looking for all occurrence, so is
explicitly searching for either /path/to/date or /path/to/DATE.  If that
matches, it will not try to normalise the name.  This is the only
arguable bug; I know you're not arguing it is a bug, but it's the only
candidate for any change that I can see.  However, it requires special
knowledge about the filing system.

On the other hand, `=' is just looking at the hash table for where
either date or DATE lives.  This gets created once and for all the first
time it searches the directory or when you do `rehash'.  In this case it
browses the directory, so gets the canonical name.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


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

* Re: PATCH: case-insensitive globbing
  2004-03-08 12:40   ` James Devenish
  2004-03-08 13:43     ` Peter Stephenson
@ 2004-03-08 13:49     ` James Devenish
  2004-03-08 16:36       ` Peter Stephenson
  1 sibling, 1 reply; 8+ messages in thread
From: James Devenish @ 2004-03-08 13:49 UTC (permalink / raw)
  To: Zsh hackers list

In message <20040308124027.GA15505@mail.guild.uwa.edu.au>
on Mon, Mar 08, 2004 at 08:40:27PM +0800, James Devenish wrote:
> In message <5792.1078749261@csr.com>
> on Mon, Mar 08, 2004 at 12:34:21PM +0000, Peter Stephenson wrote:
> > > % ls /tmp/blah
> > > DATE
> > > % rehash
> > > % where date
> > > /tmp/blah/date
> > > /bin/date

But, now I note:

% where DATE
/tmp/blah/DATE
/bin/DATE

So...fair enough. An odd experience, but does make sense. For all I
know, this might even be an Apply kludge to make ported POSIX software
work in a case-insensitive environment (I haven't looked at how zsh
queries the OS for these files). [BTW: I received your reply after I
had already written this e-mail.] On a related note:

% ls -l =date
-r-xr-xr-x  1 root  wheel  19276 24 Sep 14:51 /bin/date*
% ls -l =DATE
-r-xr-xr-x  1 admin  wheel  19276 24 Sep 14:51 /tmp/blah/DATE*

Not complaining about this -- just pointing it out so that everyone's
aware of it. I don't know how this and other such letter-case issues are
handled in Cygwin. Perhaps there could be a footnote to the caseglob


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

* Re: PATCH: case-insensitive globbing
  2004-03-08 12:40   ` James Devenish
@ 2004-03-08 13:43     ` Peter Stephenson
  2004-03-08 13:49     ` James Devenish
  1 sibling, 0 replies; 8+ messages in thread
From: Peter Stephenson @ 2004-03-08 13:43 UTC (permalink / raw)
  To: James Devenish; +Cc: Zsh hackers list

James Devenish wrote:
> In message <5792.1078749261@csr.com>
> on Mon, Mar 08, 2004 at 12:34:21PM +0000, Peter Stephenson wrote:
> > > % ls /tmp/blah
> > > DATE
> > > % rehash
> > > % where date
> > > /tmp/blah/date
> > > /bin/date
> >
> > I don't quite understand what you think is wrong.
> 
> HFS is case-preserving, so I wouldn't expect Mac OS (X or prior) to
> be returning "date" as the name instead of "DATE". It wouldn't be
> functionally incorrect to use the former, but it does seem weird
> from a Mac-user point of view.
> 

That's probably a side effect of you trying to find `date' explicitly.
It stores it under the name found in the hash table.
If you'd done `where DATE' you'd probably have seen it in upper case.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


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

* Re: PATCH: case-insensitive globbing
  2004-03-08 12:34 ` Peter Stephenson
@ 2004-03-08 12:40   ` James Devenish
  2004-03-08 13:43     ` Peter Stephenson
  2004-03-08 13:49     ` James Devenish
  0 siblings, 2 replies; 8+ messages in thread
From: James Devenish @ 2004-03-08 12:40 UTC (permalink / raw)
  To: Zsh hackers list

In message <5792.1078749261@csr.com>
on Mon, Mar 08, 2004 at 12:34:21PM +0000, Peter Stephenson wrote:
> > % ls /tmp/blah
> > DATE
> > % rehash
> > % where date
> > /tmp/blah/date
> > /bin/date
>
> I don't quite understand what you think is wrong.

HFS is case-preserving, so I wouldn't expect Mac OS (X or prior) to
be returning "date" as the name instead of "DATE". It wouldn't be
functionally incorrect to use the former, but it does seem weird
from a Mac-user point of view.



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

* Re: PATCH: case-insensitive globbing
       [not found] <20040308122200.GA13641@mail.guild.uwa.edu.au>
@ 2004-03-08 12:34 ` Peter Stephenson
  2004-03-08 12:40   ` James Devenish
  0 siblings, 1 reply; 8+ messages in thread
From: Peter Stephenson @ 2004-03-08 12:34 UTC (permalink / raw)
  To: James Devenish, Zsh hackers list

James Devenish wrote:
> Also, what about the following phenomenon (which is not usual amongst
> shells) -- is it the same under Cygwin?
> 
> % mkdir blah
> % cp -p =date blah/DATE
> % export PATH=$PWD/blah:$PATH
> % ls /tmp/blah
> DATE
> % rehash
> % where date
> /tmp/blah/date
> /bin/date
> 
> (not /tmp/blah/DATE) In this case, /tmp is on an HFS volume. Of course,
> it might be different if /tmp/blah were on a UFS volume. Might be
> awkward to calculate all this.

I don't quite understand what you think is wrong.  If /tmp/blah is on an
FS with case-insensitive file handling, as you seem to be implying (I
know nothing about HFS), isn't this the correct behaviour?

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


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

end of thread, other threads:[~2004-03-08 16:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <18393.1078742029@csr.com>
2004-03-08 12:03 ` PATCH: case-insensitive globbing Peter Stephenson
2004-03-08 13:38   ` Oliver Kiddle
2004-03-08 13:45     ` Peter Stephenson
     [not found] <20040308122200.GA13641@mail.guild.uwa.edu.au>
2004-03-08 12:34 ` Peter Stephenson
2004-03-08 12:40   ` James Devenish
2004-03-08 13:43     ` Peter Stephenson
2004-03-08 13:49     ` James Devenish
2004-03-08 16:36       ` Peter Stephenson

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).