From: Tim Starling Date: Tue, 22 Jul 2008 21:47:53 +0000 (+0000) Subject: Use a history file with readline, so that readline history is carried over from one... X-Git-Tag: 1.31.0-rc.0~46417 X-Git-Url: https://git.cyclocoop.org/admin/Duna?a=commitdiff_plain;h=640c1d398111952d9219777ff6de0141fd77a2c6;p=lhc%2Fweb%2Fwiklou.git Use a history file with readline, so that readline history is carried over from one invocation to another --- diff --git a/maintenance/eval.php b/maintenance/eval.php index 4f14a3b6d2..a990a4d845 100644 --- a/maintenance/eval.php +++ b/maintenance/eval.php @@ -39,8 +39,24 @@ if ( isset( $options['d'] ) ) { } } +if ( function_exists( 'readline_add_history' ) + && function_exists( 'posix_isatty' ) && posix_isatty( 0 /*STDIN*/ ) ) +{ + $useReadline = true; +} else { + $useReadline = false; +} + +if ( $useReadline ) { + $historyFile = "{$_ENV['HOME']}/.mweval_history"; + readline_read_history( $historyFile ); +} while ( ( $line = readconsole( '> ' ) ) !== false ) { + if ( $useReadline ) { + readline_add_history( $line ); + readline_write_history( $historyFile ); + } $val = eval( $line . ";" ); if( is_null( $val ) ) { echo "\n"; @@ -49,9 +65,6 @@ while ( ( $line = readconsole( '> ' ) ) !== false ) { } else { var_dump( $val ); } - if ( function_exists( "readline_add_history" ) ) { - readline_add_history( $line ); - } } print "\n";