Skip to content

Commit ebde3b3

Browse files
committed
Do some basic parse transforms, to handle exit; without a status.
1 parent fe10592 commit ebde3b3

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

lib/Boris/EvalWorker.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function start() {
9595

9696
$this->_cancelled = false;
9797

98-
$__input = $this->_read($this->_socket);
98+
$__input = $this->_transform($this->_read($this->_socket));
9999

100100
if ($__input === null) {
101101
continue;
@@ -228,4 +228,20 @@ private function _select(&$read, &$except) {
228228
restore_error_handler();
229229
return $result;
230230
}
231+
232+
private function _transform($input) {
233+
if ($input === null) {
234+
return null;
235+
}
236+
237+
$transforms = array(
238+
'exit' => 'exit(0)'
239+
);
240+
241+
foreach ($transforms as $from => $to) {
242+
$input = preg_replace('/^\s*' . preg_quote($from, '/') . '\s*;?\s*$/', $to . ';', $input);
243+
}
244+
245+
return $input;
246+
}
231247
}

0 commit comments

Comments
 (0)