From: Platonides Date: Sun, 11 Apr 2010 15:44:28 +0000 (+0000) Subject: Define our own posix_isatty if posix extension is not installed. X-Git-Tag: 1.31.0-rc.0~37141 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=084e5c30c384a193d4f665681eeefc3844e9d1f6;p=lhc%2Fweb%2Fwiklou.git Define our own posix_isatty if posix extension is not installed. 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 --- diff --git a/maintenance/eval.php b/maintenance/eval.php index a990a4d845..69069afa67 100644 --- a/maintenance/eval.php +++ b/maintenance/eval.php @@ -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 { diff --git a/maintenance/install-utils.inc b/maintenance/install-utils.inc index f2d48e9a0d..54a76ae2ff 100644 --- a/maintenance/install-utils.inc +++ b/maintenance/install-utils.inc @@ -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;