delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/01/12/10:23:46

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=BAYES_00,SARE_SUB_ENC_UTF8,SPF_PASS
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
Date: Tue, 12 Jan 2010 16:23:21 +0100
From: Thorsten Gunkel <tgunkel-lists AT tgunkel DOT de>
To: cygwin AT cygwin DOT com
Subject: Perl, =?UTF-8?Q?abs=5Fpath=20from=20Version=20=35=2E=31=30=2E=31-=31=20to?= =?UTF-8?Q?=20=35=2E=31=30=2E=31-=32=20changed=20behaviour=20=28no=20longe?= =?UTF-8?Q?r=20uses=20fast=5Fpath=3F=29?=
Message-ID: <6fa8f66b58b73548b9a6d0e0f8a84018@localhost>
X-Sender: tgunkel-lists AT tgunkel DOT de
User-Agent: RoundCube Webmail
X-server4-MailScanner-Information: Please contact the ISP for more information
X-server4-MailScanner: Found to be clean
X-server4-MailScanner-From: tgunkel-lists AT tgunkel DOT de
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Hi *,
I have a perl script, which stopped working, when I recently updated cygwin
to 1.7.

Here is a small demo script which shows the problem. It just calls abs_path()
with different values and prints the output. It would be great if anyone
could confirm that they also see this behaviour.


#!/bin/env perl

use strict;
use Cwd 'abs_path';

abs_path_WITHDEBUG(".");
abs_path_WITHDEBUG("C:\\");
abs_path_WITHDEBUG("C:\\Program Files\\");
abs_path_WITHDEBUG("C:\\Does Not Exist\\");
exit;

sub abs_path_WITHDEBUG
{
  my $pPath = shift;
  my $result_path=abs_path($pPath);
  print "Test: \n PrePath={".$pPath."}\nPostPath={".$result_path."}\n\n";
  return $result_path;
}



When called with current Perl Version 5.10.1-2 it shows this output:
Test:
 PrePath={.}
PostPath={/tmp}

Test:
 PrePath={C:\}
PostPath={/tmp/C:\}  <--- broken

Test:
 PrePath={C:\Program Files\}
PostPath={/tmp/C:\Program Files\}  <--- broken

Test:
 PrePath={C:\Does Not Exist\}
PostPath={/tmp/C:\Does Not Exist\}   <--- broken

Please notice, that the Windows path is justed added to the current
Unix path (which results in a broken path)


When I manually downgrade Perl to Version 5.10.1-1 it shows this output:
Test:
 PrePath={.}
PostPath={/tmp}

Test:
 PrePath={C:\}
PostPath={/cygdrive/c}

Test:
 PrePath={C:\Program Files\}
PostPath={/cygdrive/c/Program Files}

C:\Does Not Exist\: No such file or directory at ./demo.pl line 20

Here I get the correct Unix path in all cases.

The difference seems to be in Cwd.pm:

diff -u -U5 Cwd.pm*
--- Cwd.pm_old  2010-01-12 15:37:19.718007800 +0100
+++ Cwd.pm_new  2010-01-12 15:46:32.159043400 +0100
@@ -303,11 +303,11 @@
    cygwin =>
    {
     getcwd             => 'cwd',
     fastgetcwd         => 'cwd',
     fastcwd            => 'cwd',
-    abs_path           => 'fast_abs_path',
+#   abs_path           => 'fast_abs_path',
     realpath           => 'fast_abs_path',
    },
 
    epoc =>
    {
@@ -817,8 +817,8 @@
 *abs_path = \&_perl_abs_path unless defined &abs_path;
 *getcwd = \&_perl_getcwd unless defined &getcwd;
 
 # added function alias for those of us more
 # used to the libc function.  --tchrist 27-Jan-00
-*realpath = \&abs_path;
+*realpath = \&abs_path unless defined &realpath;
 
 1;

So abs_path used to point to fast_abs_path, but does not longer for Cygwin?
When I use fast_abs_path instead of abs_path in my test script it works for
both perl versions 5.10.1-1 and 5.10.1-2. What was wrong with fast_abs_path?
Should I just replace abs_path to fast_abs_path?

regards
 Thorsten


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019