r37926 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37925‎ | r37926 | r37927 >
Date:21:47, 22 July 2008
Author:tstarling
Status:old
Tags:
Comment:
Use a history file with readline, so that readline history is carried over from one invocation to another
Modified paths:
  • /trunk/phase3/maintenance/eval.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/eval.php
@@ -39,8 +39,24 @@
4040 }
4141 }
4242
 43+if ( function_exists( 'readline_add_history' )
 44+ && function_exists( 'posix_isatty' ) && posix_isatty( 0 /*STDIN*/ ) )
 45+{
 46+ $useReadline = true;
 47+} else {
 48+ $useReadline = false;
 49+}
4350
 51+if ( $useReadline ) {
 52+ $historyFile = "{$_ENV['HOME']}/.mweval_history";
 53+ readline_read_history( $historyFile );
 54+}
 55+
4456 while ( ( $line = readconsole( '> ' ) ) !== false ) {
 57+ if ( $useReadline ) {
 58+ readline_add_history( $line );
 59+ readline_write_history( $historyFile );
 60+ }
4561 $val = eval( $line . ";" );
4662 if( is_null( $val ) ) {
4763 echo "\n";
@@ -49,9 +65,6 @@
5066 } else {
5167 var_dump( $val );
5268 }
53 - if ( function_exists( "readline_add_history" ) ) {
54 - readline_add_history( $line );
55 - }
5669 }
5770
5871 print "\n";

Status & tagging log