Misapplied regex optimizations when \C is present.
[p5sagit/p5-mst-13.2.git] / lib / Cwd.pm
index 7279591..f27bd3a 100644 (file)
@@ -70,7 +70,7 @@ use strict;
 
 use Carp;
 
-our $VERSION = '2.03';
+our $VERSION = '2.04';
 
 use base qw/ Exporter /;
 our @EXPORT = qw(cwd getcwd fastcwd fastgetcwd);
@@ -91,7 +91,7 @@ sub _backtick_pwd {
 
 unless(defined &cwd) {
     # The pwd command is not available in some chroot(2)'ed environments
-    if(grep { -x "$_/pwd" } split(':', $ENV{PATH})) {
+    if($^O eq 'MacOS' || grep { -x "$_/pwd" } split(':', $ENV{PATH})) {
        *cwd = \&_backtick_pwd;
     }
     else {
@@ -99,6 +99,9 @@ unless(defined &cwd) {
     }
 }
 
+# set a reasonable (and very safe) default for fastgetcwd, in case it
+# isn't redefined later (20001212 rspier)
+*fastgetcwd = \&cwd;
 
 # By Brandon S. Allbery
 #
@@ -188,13 +191,16 @@ sub chdir_init {
 }
 
 sub chdir {
-    my $newdir = @? ? shift : '';      # allow for no arg (chdir to HOME dir)
+    my $newdir = @_ ? shift : '';      # allow for no arg (chdir to HOME dir)
     $newdir =~ s|///*|/|g unless $^O eq 'MSWin32';
     chdir_init() unless $chdir_init;
     return 0 unless CORE::chdir $newdir;
     if ($^O eq 'VMS') {
        return $ENV{'PWD'} = $ENV{'DEFAULT'}
     }
+    elsif ($^O eq 'MacOS') {
+       return $ENV{'PWD'} = cwd();
+    }
     elsif ($^O eq 'MSWin32') {
        $ENV{'PWD'} = Win32::GetFullPathName($newdir);
        return 1;
@@ -408,11 +414,18 @@ sub _epoc_cwd {
         *abs_path      = \&fast_abs_path;
     }
     elsif ($^O eq 'epoc') {
-        *getcwd        = \&_epoc_cwd;
+        *cwd            = \&_epoc_cwd;
+        *getcwd                = \&_epoc_cwd;
         *fastgetcwd    = \&_epoc_cwd;
         *fastcwd       = \&_epoc_cwd;
         *abs_path      = \&fast_abs_path;
     }
+    elsif ($^O eq 'MacOS') {
+       *getcwd     = \&cwd;
+       *fastgetcwd = \&cwd;
+       *fastcwd    = \&cwd;
+       *abs_path   = \&fast_abs_path;
+    }
 }
 
 # package main; eval join('',<DATA>) || die $@;        # quick test