Skip to content

Support eval-file from stdin (implementation for #19)#21

Merged
schlessera merged 4 commits intowp-cli:masterfrom
pjeby:master
Feb 21, 2018
Merged

Support eval-file from stdin (implementation for #19)#21
schlessera merged 4 commits intowp-cli:masterfrom
pjeby:master

Conversation

@pjeby
Copy link
Copy Markdown
Contributor

@pjeby pjeby commented Feb 17, 2018

Per issue #19, this PR implements the ability to wp eval-file code from php://stdin, using - for consistency with other wp-cli commands that take input from stdin.

private static function _eval( $file, $args ) {
include( $file );
if ( "-" === $file ) {
eval( "?>" . file_get_contents("php://stdin"));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WPCS: Missing spaces around parentheses, and unnecessary double quote string:

eval( "?>" . file_get_contents( 'php://stdin' ) );

if ( "-" === $file ) {
eval( "?>" . file_get_contents("php://stdin"));
} else {
include( $file );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No parentheses needed, include is not a function:

include $file;

Note: I know this is only taken from the previous code, but we can fix it anyway while we're making changes here.

README.md Outdated

<file>
The path to the PHP file to execute.
The path to the PHP file to execute. Use '-' to run code from stdin.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually refer to STDIN (all caps).

*
* <file>
* : The path to the PHP file to execute.
* : The path to the PHP file to execute. Use '-' to run code from stdin.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually refer to STDIN (all caps).

@schlessera
Copy link
Copy Markdown
Member

Hey @pjeby ,
Thanks for the pull request.
Everything's fine with the code, I just have a few small nitpicks regarding the form. As soon as you can push a change with the small details, this is good to be merged.

@schlessera schlessera added the command:eval-file Related to 'eval-file' command label Feb 20, 2018
@pjeby
Copy link
Copy Markdown
Contributor Author

pjeby commented Feb 20, 2018

Done.

@schlessera schlessera merged commit 7d81db1 into wp-cli:master Feb 21, 2018
@schlessera schlessera added this to the 1.0.6 milestone Feb 21, 2018
schlessera added a commit that referenced this pull request Jan 5, 2022
Support eval-file from stdin (implementation for #19)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:eval-file Related to 'eval-file' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants