Define our own posix_isatty if posix extension is not installed.
authorPlatonides <platonides@users.mediawiki.org>
Sun, 11 Apr 2010 15:44:28 +0000 (15:44 +0000)
committerPlatonides <platonides@users.mediawiki.org>
Sun, 11 Apr 2010 15:44:28 +0000 (15:44 +0000)
Removes the extension dependency on non-windows for parserTests.
Currently used on install-utils.inc readconsole(), eval.php and parserTests.inc

Maintenance scripts receive it via commandLine.inc -> Maintenance.php .. doMaintenance.php -> install-utils.inc

maintenance/eval.php
maintenance/install-utils.inc

index a990a4d..69069af 100644 (file)
@@ -40,7 +40,7 @@ if ( isset( $options['d'] ) ) {
 }
 
 if ( function_exists( 'readline_add_history' ) 
-       && function_exists( 'posix_isatty' ) && posix_isatty( 0 /*STDIN*/ ) ) 
+       && posix_isatty( 0 /*STDIN*/ ) ) 
 {
        $useReadline = true;
 } else {
index f2d48e9..54a76ae 100644 (file)
@@ -95,10 +95,18 @@ class PhpRefCallBugTester {
        }
 }
 
+if ( !function_exists( 'posix_isatty' ) ) {
+       # We default as considering stdin a tty (for nice readline methods)
+       # but treating stout as not a tty to avoid color codes
+       function posix_isatty( $fd ) {
+               return !$fd;
+       }
+}
+
 function readconsole( $prompt = '' ) {
        static $isatty = null;
        if ( is_null( $isatty ) ) {
-               if ( !function_exists( 'posix_isatty' ) || posix_isatty( 0 /*STDIN*/ ) ) {
+               if ( posix_isatty( 0 /*STDIN*/ ) ) {
                        $isatty = true;
                } else {
                        $isatty = false;