Merge pull request #226 from KeenS/repl-batch

Repl batch
This commit is contained in:
Yuichi Nishiwaki 2014-10-02 00:37:01 +09:00
commit aa3982890a
3 changed files with 24 additions and 1 deletions

View File

@ -1 +1,3 @@
list(APPEND PICLIB_CONTRIB_LIBS ${PROJECT_SOURCE_DIR}/contrib/20.repl/repl.scm)
list(APPEND PICRIN_CONTRIB_SOURCES ${PROJECT_SOURCE_DIR}/contrib/20.repl/repl.c)
list(APPEND PICRIN_CONTRIB_INITS repl)

21
contrib/20.repl/repl.c Normal file
View File

@ -0,0 +1,21 @@
#include "picrin.h"
#include <unistd.h>
static pic_value
pic_repl_tty_p(pic_state *pic)
{
pic_get_args(pic, "");
return pic_bool_value((isatty(STDIN_FILENO)));
}
void
pic_init_repl(pic_state *pic)
{
pic_deflibrary (pic, "(picrin repl)") {
pic_defun(pic, "tty?", pic_repl_tty_p);
}
}

View File

@ -11,7 +11,7 @@
(else
(begin
(define (readline str)
(display str)
(if (tty?) (display str))
(read-line))
(define (add-history str)
#f))))