save history also for failed commands in repl

This commit is contained in:
Pekka Laiho 2020-06-19 19:20:31 +07:00
parent ad2aea9c70
commit 325a1bcaf0

10
run.php
View File

@ -18,11 +18,6 @@ function ml_repl($lisp)
try { try {
$lisp->rep($input, true); $lisp->rep($input, true);
if ($input) {
readline_add_history($input);
readline_write_history($historyFile);
}
} catch (MadLisp\MadLispException $ex) { } catch (MadLisp\MadLispException $ex) {
print('error: ' . $ex->getMessage()); print('error: ' . $ex->getMessage());
} catch (TypeError $ex) { } catch (TypeError $ex) {
@ -30,6 +25,11 @@ function ml_repl($lisp)
} }
print(PHP_EOL); print(PHP_EOL);
if ($input) {
readline_add_history($input);
readline_write_history($historyFile);
}
} }
} }