From: Tim Starling Date: Fri, 21 Nov 2003 05:00:22 +0000 (+0000) Subject: Support for systems without readline X-Git-Tag: 1.1.0~118 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=17428f7d2f9903698fda0de09ccb206860e314e3;p=lhc%2Fweb%2Fwiklou.git Support for systems without readline --- 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; + } +} + + + ?>