Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File::Spec->case_tolerant() should return true on Cygwin #8555

Closed
p5pRT opened this issue Aug 7, 2006 · 13 comments
Closed

File::Spec->case_tolerant() should return true on Cygwin #8555

p5pRT opened this issue Aug 7, 2006 · 13 comments

Comments

@p5pRT
Copy link

p5pRT commented Aug 7, 2006

Migrated from rt.perl.org#40103 (status was 'resolved')

Searchable as RT40103$

@p5pRT
Copy link
Author

p5pRT commented Aug 7, 2006

From g.paulissen@chello.nl

This is a bug report for perl from g.paulissen@​chello.nl,
generated with the help of perlbug 1.35 running under perl v5.8.4.


In think the File​::Spec​::Cygwin case_tolerant() should return true (1) instead of false (0).

$ perl -e "use File​::Spec; print File​::Spec->case_tolerant();"
0

Why?

Have a look at the following commands​:

$ which sqlplus
/cygdrive/c/Oracle/product/10.1.0/Db__4/bin/sqlplus

$ ln -s /cygdrive/c/Oracle/product/10.1.0/Db__4/bin/sqlplus SQLPLUS.exe

$ PATH=.​:$PATH

$ which sqlplus
./sqlplus

So although the executable is named SQLPLUS.exe, which still can find it.



Flags​:
  category=library
  severity=medium


Site configuration information for perl v5.8.4​:

Configured by ActiveState at Tue Jun 1 11​:52​:09 2004.

Summary of my perl5 (revision 5 version 8 subversion 4) configuration​:
  Platform​:
  osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread
  uname=''
  config_args='undef'
  hint=recommended, useposix=true, d_sigaction=undef
  usethreads=undef use5005threads=undef useithreads=define usemultiplicity=define
  useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
  use64bitint=undef use64bitall=undef uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='cl', ccflags ='-nologo -Gf -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DNO_HASH_SEED -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX',
  optimize='-MD -Zi -DNDEBUG -O1',
  cppflags='-DWIN32'
  ccversion='', gccversion='', gccosandvers=''
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
  d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
  ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64', lseeksize=8
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='link', ldflags ='-nologo -nodefaultlib -debug -opt​:ref,icf -libpath​:"C​:\Progra1\Perl\lib\CORE" -machine​:x86'
  libpth=C​:\PROGRA
1\MICROS3\VC98\lib
  libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib
  perllibs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib
  libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl58.lib
  gnulibc_version='undef'
  Dynamic Linking​:
  dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
  cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug -opt​:ref,icf -libpath​:"C​:\Progra
1\Perl\lib\CORE" -machine​:x86'

Locally applied patches​:
  ACTIVEPERL_LOCAL_PATCHES_ENTRY
  22751 Update to Test.pm 1.25
  21540 Fix backward-compatibility issues in if.pm


@​INC for perl v5.8.4​:
  h​:\work\isr\scripts
  h​:\work\isr\build\ISR\scripts
  C​:/Program Files/Perl/lib
  C​:/Program Files/Perl/site/lib
  .


Environment for perl v5.8.4​:
  HOME (unset)
  LANG (unset)
  LANGUAGE (unset)
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=h​:\work\isr\scripts;h​:\work\isr\build\ISR\scripts;h​:\work\tw\common\src\perl;C​:\Oracle\product\10.1.0\Db__4\bin;C​:\Oracle\product\10.1.0\Db__4\jre\1.4.2\bin\client;C​:\Oracle\product\10.1.0\Db__4\jre\1.4.2\bin;C​:\oracle\product\10.2.0\client_1\bin;k​:\oap\isr\dev\ant\bin;c​:\usr\local\wbin;C​:\oraclexe\app\oracle\product\10.2.0\server\bin;C​:\Progra1\Perl\bin;C​:\DS10G\jre\1.1.8\bin;C​:\DS10G\jlib;C​:\DS10G\jdk\jre\bin\client;C​:\DS10G\jdk\jre\bin;C​:\DS10G\jdk\jre\bin\classic;C​:\DS10G\jre\1.4.1\bin;C​:\DS10G\bin;C​:\WINDOWS\system32;C​:\WINDOWS;C​:\WINDOWS\System32\Wbem;C​:\ORANT\bin;C​:\Program Files\Oracle\jre\1.1.7\bin;C​:\ORANT\jdk\bin;C​:\ORANT\REPADM61\jre1_4\bin;C​:\ORANT\REPADM61\jre1_4\bin\client;C​:\DES_817\bin;C​:\Program Files\Rumba\Windows;C​:\Program Files\ora817\bin;C​:\Program Files\Java\j2sdk1.4.2_10\bin;C​:\Progra1\ora817\bin;C​:\Program Files\COMMON1\Crystal Decisions\2.0\bin;C​:\Program Files\Hummingbird\Connectivity\10.00\Accessories;h​:\work\pldoc;c​:\progra1\putty
  PERLLIB=h​:\work\isr\scripts;h​:\work\isr\build\ISR\scripts
  PERL_BADLANG (unset)
  SHELL (unset)

@p5pRT
Copy link
Author

p5pRT commented Sep 15, 2006

From @schwern

g.paulissen@​chello.nl (via RT) wrote​:

-----------------------------------------------------------------
In think the File​::Spec​::Cygwin case_tolerant() should return true (1) instead of false (0).

$ perl -e "use File​::Spec; print File​::Spec->case_tolerant();"
0

Why?

Have a look at the following commands​:

$ which sqlplus
/cygdrive/c/Oracle/product/10.1.0/Db__4/bin/sqlplus

$ ln -s /cygdrive/c/Oracle/product/10.1.0/Db__4/bin/sqlplus SQLPLUS.exe

$ PATH=.​:$PATH

$ which sqlplus
./sqlplus

So although the executable is named SQLPLUS.exe, which still can find it.

-----------------------------------------------------------------

Is that magic in which or is that magic in the filesystem? I know Cygwin's which is already pretty magical with regard to .exe.

A simple way to test this is​:

open FILE, ">this is a test file" or die $!;
print FILE "wibble\n";
close FILE;

print open(FILE, "This is a Test FILE") ? "Tolerant" : "Intolerant";

@p5pRT
Copy link
Author

p5pRT commented Sep 15, 2006

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jun 20, 2007

From @rurban

Attached patch fixes #40103 for blead.
--
Reini Urban

@p5pRT
Copy link
Author

p5pRT commented Jun 20, 2007

From @rurban

pl-#40103-File-Spec-case_tolerant.patch
--- perl-5.9.5/lib/File/Spec/Cygwin.pm.orig	2006-11-23 03:13:19.000000000 +0000
+++ perl-5.9.5/lib/File/Spec/Cygwin.pm	2007-06-20 17:25:13.625000000 +0000
@@ -4,7 +4,7 @@
 use vars qw(@ISA $VERSION);
 require File::Spec::Unix;
 
-$VERSION = '1.1';
+$VERSION = '1.2';
 
 @ISA = qw(File::Spec::Unix);
 
@@ -97,6 +97,15 @@
     $tmpdir = $_[0]->_tmpdir( $ENV{TMPDIR}, "/tmp", 'C:/temp' );
 }
 
+=item case_tolerant
+
+Override Unix. Cygwin is always case-tolerant, indicating that it is not
+significant when comparing file specifications.
+
+=cut
+
+sub case_tolerant () { 1 }
+
 =back
 
 =head1 COPYRIGHT

@p5pRT
Copy link
Author

p5pRT commented Jun 20, 2007

From @rurban

On Wed Jun 20 10​:27​:50 2007, rurban wrote​:

Attached patch fixes #40103 for blead.

Oops, forgot the test.
The attached patch fixes #40103 for blead and corerects the test.

--
Reini Urban

@p5pRT
Copy link
Author

p5pRT commented Jun 20, 2007

From @rurban

pl-#40103-File-Spec-case_tolerant.patch
--- perl-5.9.5/lib/File/Spec/Cygwin.pm.orig	2006-11-23 03:13:19.000000000 +0000
+++ perl-5.9.5/lib/File/Spec/Cygwin.pm	2007-06-20 17:25:13.625000000 +0000
@@ -4,7 +4,7 @@
 use vars qw(@ISA $VERSION);
 require File::Spec::Unix;
 
-$VERSION = '1.1';
+$VERSION = '1.2';
 
 @ISA = qw(File::Spec::Unix);
 
@@ -97,6 +97,15 @@
     $tmpdir = $_[0]->_tmpdir( $ENV{TMPDIR}, "/tmp", 'C:/temp' );
 }
 
+=item case_tolerant
+
+Override Unix. Cygwin is always case-tolerant, indicating that it is not
+significant when comparing file specifications.
+
+=cut
+
+sub case_tolerant () { 1 }
+
 =back
 
 =head1 COPYRIGHT
--- perl-5.9.5/lib/File/Spec/t/Spec.t.orig	2006-10-12 15:10:26.000000000 +0000
+++ perl-5.9.5/lib/File/Spec/t/Spec.t	2007-06-20 18:48:37.406250000 +0000
@@ -618,7 +618,7 @@
 #[ "Epoc->canonpath('/a/.')",                                  '/a'        ],
 #[ "Epoc->canonpath('/.')",                                    '/'         ],
 
-[ "Cygwin->case_tolerant()",         '0'  ],
+[ "Cygwin->case_tolerant()",         '1'  ],
 [ "Cygwin->catdir('/','d2/d3')",     '/d2/d3'  ],
 
 ) ;

@p5pRT
Copy link
Author

p5pRT commented Jun 21, 2007

@rgs - Status changed from 'open' to 'resolved'

@p5pRT p5pRT closed this as completed Jun 21, 2007
@p5pRT
Copy link
Author

p5pRT commented Jun 21, 2007

From @rgs

On 20/06/07, Reini Urban via RT <perlbug-followup@​perl.org> wrote​:

On Wed Jun 20 10​:27​:50 2007, rurban wrote​:

Attached patch fixes #40103 for blead.

Oops, forgot the test.
The attached patch fixes #40103 for blead and corerects the test.

Thanks, applied, bumping the version to 1.1_01.

@p5pRT
Copy link
Author

p5pRT commented Jun 22, 2007

From @wb8tyw

Reini Urban via RT wrote​:

Attached patch fixes #40103 for blead.

Isn't the case tolerant setting something that could be on the file
system that Cygwin must honor? Or is Cygwin forcing the setting to be
insensitive?

Windows has the option of setting the file system to be case sensitive.
  I do not know at the present time if it is on a per process and
children setting or if it is a file system or even directory property.

On VMS it is a per-process setting, but only affects the ODS-5 file system.

-John
wb8tyw@​qsl.net
Personal Opinion Only

@p5pRT
Copy link
Author

p5pRT commented Jul 8, 2007

From @rurban

On Thu Jun 21 01​:39​:59 2007, rafael wrote​:

On 20/06/07, Reini Urban via RT <perlbug-followup <!-- x --> at
perl.org> wrote​:

On Wed Jun 20 10​:27​:50 2007, rurban wrote​:

Attached patch fixes #40103 for blead.

Oops, forgot the test.
The attached patch fixes #40103 for blead and corerects the test.

Thanks, applied, bumping the version to 1.1_01.

And this patch is for maint and bumps the version to 1.1_02

This also adds "Handle network path names beginning with double slash"
from blead.
And I added another check for $ENV{'TMP'}, and $ENV{'TEMP'} in tempdir
See http​://cygwin.com/ml/cygwin/2007-07/msg00119.html

--
Reini Urban

@p5pRT
Copy link
Author

p5pRT commented Jul 8, 2007

From @rurban

pl-40103-File-Spec-case_tolerant_2.patch
difforig perl-5.8.8/lib/File/Spec

2007-07-08  Reini Urban <rurban@x-ray.at>

diff -ub  perl-5.8.8/lib/File/Spec/Cygwin.pm.orig
--- perl-5.8.8/lib/File/Spec/Cygwin.pm.orig	2005-05-06 16:03:10.000000000 +0000
+++ perl-5.8.8/lib/File/Spec/Cygwin.pm	2007-07-08 11:35:13.227000000 +0000
@@ -4,7 +4,7 @@
 use vars qw(@ISA $VERSION);
 require File::Spec::Unix;
 
-$VERSION = '1.1';
+$VERSION = '1.1_02';
 
 @ISA = qw(File::Spec::Unix);
 
@@ -40,7 +40,25 @@
 sub canonpath {
     my($self,$path) = @_;
     $path =~ s|\\|/|g;
-    return $self->SUPER::canonpath($path);
+
+    # Handle network path names beginning with double slash
+    my $node = '';
+    if ( $path =~ s@^(//[^/]+)(?:/|\z)@/@s ) {
+        $node = $1;
+    }
+    return $node . $self->SUPER::canonpath($path);
+}
+
+sub catdir {
+    my $self = shift;
+
+    # Don't create something that looks like a //network/path
+    if ($_[0] and ($_[0] eq '/' or $_[0] eq '\\')) {
+        shift;
+        return $self->SUPER::catdir('', @_);
+    }
+
+    $self->SUPER::catdir(@_);
 }
 
 =pod
@@ -66,6 +84,8 @@
 
     $ENV{TMPDIR}
     /tmp
+    $ENV{'TMP'}
+    $ENV{'TEMP'}
     C:/temp
 
 Since Perl 5.8.0, if running under taint mode, and if the environment
@@ -76,9 +96,18 @@
 my $tmpdir;
 sub tmpdir {
     return $tmpdir if defined $tmpdir;
-    $tmpdir = $_[0]->_tmpdir( $ENV{TMPDIR}, "/tmp", 'C:/temp' );
+    $tmpdir = $_[0]->_tmpdir( $ENV{TMPDIR}, "/tmp", $ENV{'TMP'}, $ENV{'TEMP'}, 'C:/temp' );
 }
 
+=item case_tolerant
+
+Override Unix. Cygwin is always case-tolerant, indicating that it is not
+significant when comparing file specifications.
+
+=cut
+
+sub case_tolerant () { 1 }
+
 =back
 
 =head1 COPYRIGHT
diff -ub  perl-5.8.8/lib/File/Spec/t/Spec.t.orig
--- perl-5.8.8/lib/File/Spec/t/Spec.t.orig	2005-08-27 17:26:19.000000000 +0000
+++ perl-5.8.8/lib/File/Spec/t/Spec.t	2007-07-08 12:12:06.242625000 +0000
@@ -595,7 +595,7 @@
 #[ "Epoc->canonpath('/a/.')",                                  '/a'        ],
 #[ "Epoc->canonpath('/.')",                                    '/'         ],
 
-[ "Cygwin->case_tolerant()",         '0'  ],
+[ "Cygwin->case_tolerant()",         '1'  ],
 
 ) ;
 

@p5pRT
Copy link
Author

p5pRT commented Jul 8, 2007

From @rurban

On Thu Jun 21 19​:52​:13 2007, malmberg wrote​:

Reini Urban via RT wrote​:

Attached patch fixes #40103 for blead.

Isn't the case tolerant setting something that could be on the file
system that Cygwin must honor? Or is Cygwin forcing the setting to be
insensitive?

Windows has the option of setting the file system to be case sensitive.
I do not know at the present time if it is on a per process and
children setting or if it is a file system or even directory property.

On VMS it is a per-process setting, but only affects the ODS-5 file
system.

This is true, but rarely used and impossible to check (yet).
We really should check for a managed mount, and for some registry
setting (?) where the case-sensitivity can be overruled.
The registry API is not in CORE and a mount API also not (yet).

For the managed mount I have to extend the Cygwin API for something like
Cygwin​::mount_flags(pathname, [flag]) => @​ or BOOL
flag and/or return array one of
qw(text binary managed user system exec notexec cygexec nosuid)
--
Reini Urban

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant