Skip to content

Commit

Permalink
always include a newline after non-null eval output
Browse files Browse the repository at this point in the history
  • Loading branch information
JRGould committed Apr 14, 2016
1 parent 1e439ad commit 6d84612
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion php/WP_CLI/REPL.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,22 @@ public function start() {
$line = rtrim( $line, ';' ) . ';';

if ( self::starts_with( self::non_expressions(), $line ) ) {
ob_start();
eval( $line );
$out = ob_get_clean();
if ( 0 < strlen ( $out ) ) {
$out = rtrim( $out, "\n" ) . "\n";
}
fwrite( STDOUT, $out );
} else {
if ( !self::starts_with( 'return', $line ) )
$line = 'return ' . $line;

// Write directly to STDOUT, to sidestep any output buffers created by plugins
ob_start();
var_dump( eval( $line ) );
fwrite( STDOUT, ob_get_clean() );
$out = rtrim( ob_get_clean(), "\n" ) . "\n";
fwrite( STDOUT, $out );
}
}
}
Expand Down

0 comments on commit 6d84612

Please sign in to comment.