From: Tim Starling Date: Thu, 8 Sep 2005 08:49:04 +0000 (+0000) Subject: Added isatty() check to readconsole() X-Git-Tag: 1.6.0~1693 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmes_infos.php?a=commitdiff_plain;h=bc17c6a9856f3031845d42767cca7032fde40be9;p=lhc%2Fweb%2Fwiklou.git Added isatty() check to readconsole() --- diff --git a/install-utils.inc b/install-utils.inc index faabab61ba..6de9377428 100644 --- a/install-utils.inc +++ b/install-utils.inc @@ -57,10 +57,18 @@ function copydirectory( $source, $dest ) { } function readconsole( $prompt = '' ) { - if ( function_exists( 'readline' ) ) { + if ( function_exists( 'posix_isatty' ) && posix_isatty( STDIN ) ) { + $isatty = true; + } else { + $isatty = false; + } + + if ( $isatty && function_exists( 'readline' ) ) { return readline( $prompt ); } else { - print $prompt; + if ( $isatty ) { + print $prompt; + } $fp = fopen( 'php://stdin', 'r' ); $st = fgets($fp, 1024); if ($st === false) return false;