From 17428f7d2f9903698fda0de09ccb206860e314e3 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Fri, 21 Nov 2003 05:00:22 +0000 Subject: [PATCH] Support for systems without readline --- maintenance/mcc.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/maintenance/mcc.php b/maintenance/mcc.php index 5bf56da6d4..1ea43caaad 100755 --- a/maintenance/mcc.php +++ b/maintenance/mcc.php @@ -9,7 +9,7 @@ $mcc->set_servers( $wgMemCachedServers ); do { $bad = false; $quit = false; - $line = readline( "> " ); + $line = readconsole( "> " ); $args = explode( " ", $line ); $command = array_shift( $args ); switch ( $command ) { @@ -40,8 +40,25 @@ do { print "Bad command\n"; } } else { - readline_add_history( $line ); + if ( function_exists( "readline_add_history" ) ) { + readline_add_history( $line ); + } } } while ( !$quit ); + +function readconsole( $prompt = "" ) { + if ( function_exists( "readline" ) ) { + return readline( $prompt ); + } else { + print $prompt; + $fp = fopen( "php://stdin", "r" ); + $resp = trim( fgets( $fp, 1024 ) ); + fclose( $fp ); + return $resp; + } +} + + + ?> -- 2.20.1