mirror of
https://github.com/kanaka/mal.git
synced 2024-09-22 02:58:15 +03:00
c9de2e82ed
- tests/docker/Dockerfile: specifies full docker image containing all tools/languages (except matlab). - tests/docker-build.sh: build above image. - tests/docker-run.sh: launch above image. Example: ./tests/docker-run.sh make test^js^step2 - Various fixes across multiple languages: - Unicode fixes for bash and R on Ubuntu Utopic - readline history fixes for when ~/.mal-history is not available or readable/writable. No fatal errors. - fixes to work with perl 5.20 (and still perl 5.18)
39 lines
902 B
PHP
39 lines
902 B
PHP
<?php
|
|
|
|
$HISTORY_FILE = $_SERVER['HOME'] . "/.mal-history";
|
|
|
|
function mal_readline($prompt) {
|
|
global $HISTORY_FILE;
|
|
static $history_loaded = false;
|
|
|
|
// Load the history file
|
|
if (! $history_loaded) {
|
|
$history_loaded = true;
|
|
if (is_readable($HISTORY_FILE)) {
|
|
if ($file = fopen($HISTORY_FILE, "r")) {
|
|
while (!feof($file)) {
|
|
$line = fgets($file);
|
|
if ($line) { readline_add_history($line); }
|
|
}
|
|
fclose($file);
|
|
}
|
|
}
|
|
}
|
|
|
|
$line = readline($prompt);
|
|
if ($line === false) { return NULL; }
|
|
readline_add_history($line);
|
|
|
|
// Append to the history file
|
|
if (is_writable($HISTORY_FILE)) {
|
|
if ($file = fopen($HISTORY_FILE, "a")) {
|
|
fputs($file, $line . "\n");
|
|
fclose($file);
|
|
}
|
|
}
|
|
|
|
return $line;
|
|
}
|
|
|
|
?>
|