From 084e5c30c384a193d4f665681eeefc3844e9d1f6 Mon Sep 17 00:00:00 2001 From: Platonides Date: Sun, 11 Apr 2010 15:44:28 +0000 Subject: [PATCH] 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 --- maintenance/eval.php | 2 +- maintenance/install-utils.inc | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) 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; -- 2.20.1