OSDN Git Service

remove support for $_ special variable, since Boris doesn't support it.
authorscribu <mail@scribu.net>
Wed, 8 May 2013 12:10:12 +0000 (15:10 +0300)
committerscribu <mail@scribu.net>
Wed, 8 May 2013 12:43:16 +0000 (15:43 +0300)
features/shell.feature
man-src/shell.txt
php/WP_CLI/REPL.php

index 2cc9c47..a880b91 100644 (file)
@@ -10,26 +10,6 @@ Feature: WordPress REPL
     Type "exit" to close session.
     """
 
-  Scenario: $_ special variable
-    Given a WP install
-    And a session file:
-    """
-    WP_ADMIN
-    $_
-    get_current_user_id()
-    $_
-    """
-
-    When I run `wp shell --quiet < session`
-    Then it should run without errors
-    And STDOUT should be:
-    """
-    true
-    true
-    0
-    0
-    """
-
   Scenario: Persistent environment
     Given a WP install
     And a session file:
index da5393c..02f84c9 100644 (file)
@@ -2,8 +2,6 @@
 
 `wp shell` allows you to evaluate PHP statements and expressions interactively, from within a WordPress environment. This means that you have access to all the functions, classes and globals that you would have access to from inside a WordPress plugin, for example.
 
-`$_` is a special variable that contains the result from the last evaluated statement.
-
 You can split a statement over multiple lines by adding a `\` (backslash) before hitting Return.
 
 If you type `history` and hit Return, WP-CLI will print the list of previously evaluated statements, which you can copy+paste into a PHP file.
index 93e4377..830404d 100644 (file)
@@ -32,14 +32,10 @@ class REPL {
                        if ( self::starts_with( self::non_expressions(), $line ) ) {
                                eval( $line );
                        } else {
-                               if ( self::starts_with( 'return', $line ) )
-                                       $line = substr( $line, strlen( 'return' ) );
+                               if ( !self::starts_with( 'return', $line ) )
+                                       $line = 'return ' . $line;
 
-                               $line = '$_ = ' . $line;
-
-                               eval( $line );
-
-                               \WP_CLI::print_value( var_export( $_, false ) );
+                               \WP_CLI::print_value( var_export( eval( $line ), false ) );
                        }
                }
        }