MDL-34885 phpunit: better cygwin detection.
authorTim Hunt <T.J.Hunt@open.ac.uk>
Tue, 14 Aug 2012 13:06:24 +0000 (14:06 +0100)
committerTim Hunt <T.J.Hunt@open.ac.uk>
Tue, 14 Aug 2012 13:12:06 +0000 (14:12 +0100)
For some reason, on my computer, $_SERVER['SHELL'] was not set, so I
changed the test to also consider $_SERVER['TERM']. This now works for
me.

lib/phpunit/bootstraplib.php

index bc74dc9..b7c9fde 100644 (file)
@@ -150,8 +150,16 @@ function phpunit_boostrap_fix_file_permissions($file) {
  * @return bool
  */
 function phpunit_bootstrap_is_cygwin() {
-    if (empty($_SERVER['SHELL']) or empty($_SERVER['OS'])) {
+    if (empty($_SERVER['OS']) or $_SERVER['OS'] !== 'Windows_NT') {
+        return false;
+
+    } else if (!empty($_SERVER['SHELL']) and $_SERVER['SHELL'] === '/bin/bash') {
+        return true;
+
+    } else if (!empty($_SERVER['TERM']) and $_SERVER['TERM'] === 'cygwin') {
+        return true;
+
+    } else {
         return false;
     }
-    return ($_SERVER['OS'] === 'Windows_NT' and $_SERVER['SHELL'] === '/bin/bash');
 }