Permalink
Browse files

Fixed a bug with assignment introduced in 4afa0af.

Refactoring the `eval()` statements to a separate function won't work as assignment in phpsh relies on `eval()` scoping variables inside `___Phpsh___::interactive_loop()`.
  • Loading branch information...
1 parent 4afa0af commit de65124869f9c845e8c51a8d7efff6078d85fcbf @whatthejeff whatthejeff committed Sep 8, 2010
Showing with 19 additions and 20 deletions.
  1. +19 −20 src/phpsh.php
View
@@ -492,24 +492,6 @@ function undefined_function_check($buffer) {
return '';
}
- /**
- * eval with exception handling
- */
- function eval_and_handle($buffer) {
- try {
- $evalue = eval($buffer);
- } catch (Exception $e) {
- // unfortunately, almost all exceptions that aren't explicitly
- // thrown by users are uncatchable :(
- fwrite(STDERR,
- 'Uncaught exception: '.get_class($e).': '.
- $e->getMessage()."\n".
- $e->getTraceAsString()."\n");
- $evalue = null;
- }
- return $evalue;
- }
-
/**
* The main interactive loop
*
@@ -565,13 +547,30 @@ function interactive_loop() {
if ($pid) {
pcntl_wait($status);
} else {
- $evalue = $this->eval_and_handle($buffer);
+ try {
+ $evalue = eval($buffer);
+ } catch (Exception $e) {
+ // unfortunately, almost all exceptions that aren't explicitly
+ // thrown by users are uncatchable :(
+ fwrite(STDERR, 'Uncaught exception: '.get_class($e).': '.
+ $e->getMessage()."\n".$e->getTraceAsString()."\n");
+ $evalue = null;
+ }
+
// if we are still alive..
$childpid = posix_getpid();
fwrite($this->_comm_handle, "child $childpid\n");
}
} else {
- $evalue = $this->eval_and_handle($buffer);
+ try {
+ $evalue = eval($buffer);
+ } catch (Exception $e) {
+ // unfortunately, almost all exceptions that aren't explicitly thrown
+ // by users are uncatchable :(
+ fwrite(STDERR, 'Uncaught exception: '.get_class($e).': '.
+ $e->getMessage()."\n".$e->getTraceAsString()."\n");
+ $evalue = null;
+ }
}
if ($buffer != "xdebug_break();\n") {

0 comments on commit de65124

Please sign in to comment.