]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
pathhelp.pm: fix use of pwd -L in Msys environment
authorMarc Hoersken <info@marc-hoersken.de>
Wed, 11 Nov 2020 20:20:20 +0000 (21:20 +0100)
committerMarc Hoersken <info@marc-hoersken.de>
Mon, 1 Mar 2021 19:18:04 +0000 (20:18 +0100)
While Msys2 has a pwd binary which supports -L,
Msys1 only has a shell built-in with that feature.

Reviewed-by: Jay Satiro
Part of #6179

tests/pathhelp.pm

index f3bdc5bdf91e06853651330a7a58ec2ee26b8ca5..0603d509ddd786e9f01d8f9ae15bf63c8b5ba338 100644 (file)
@@ -372,7 +372,15 @@ sub sys_native_abs_path {
         # Path is in relative form. Resolve relative directories in Unix form
         # *BEFORE* converting to Win32 form otherwise paths like
         # '../../../cygdrive/c/windows' will not be resolved.
-        my $cur_dir = `pwd -L`;
+
+        my $cur_dir;
+        # MSys shell has built-in command.
+        if($^O eq 'msys') {
+            $cur_dir = `bash -c 'pwd -L'`;
+        }
+        else {
+            $cur_dir = `pwd -L`;
+        }
         if($? != 0) {
             warn "Can't determine current working directory.\n";
             return undef;
@@ -440,7 +448,13 @@ sub build_sys_abs_path {
         # Path is empty string. Return current directory.
         # Empty string processed correctly by 'cygpath'.
 
-        chomp($path = `pwd -L`);
+        # MSys shell has built-in command.
+        if($^O eq 'msys') {
+            chomp($path = `bash -c 'pwd -L'`);
+        }
+        else {
+            chomp($path = `pwd -L`);
+        }
         if($? != 0) {
             warn "Can't determine Unix-style current working directory.\n";
             return undef;
@@ -510,7 +524,15 @@ sub build_sys_abs_path {
         # Path in relative form. Resolve relative directories in Unix form
         # *BEFORE* converting to Win32 form otherwise paths like
         # '../../../cygdrive/c/windows' will not be resolved.
-        my $cur_dir = `pwd -L`;
+
+        my $cur_dir;
+        # MSys shell has built-in command.
+        if($^O eq 'msys') {
+            $cur_dir = `bash -c 'pwd -L'`;
+        }
+        else {
+            $cur_dir = `pwd -L`;
+        }
         if($? != 0) {
             warn "Can't determine current working directory.\n";
             return undef;