unix: Allow to cat a script into stdin from the command line.

See issue #1306.
This commit is contained in:
Damien George
2015-06-04 23:42:45 +01:00
parent 9724a0538b
commit 031278f661
4 changed files with 36 additions and 11 deletions

View File

@@ -30,6 +30,7 @@
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <ctype.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -447,9 +448,14 @@ int main(int argc, char **argv) {
}
if (ret == NOTHING_EXECUTED) {
prompt_read_history();
ret = do_repl();
prompt_write_history();
if (isatty(0)) {
prompt_read_history();
ret = do_repl();
prompt_write_history();
} else {
mp_lexer_t *lex = mp_lexer_new_from_fd(MP_QSTR__lt_stdin_gt_, 0, false);
ret = execute_from_lexer(lex, MP_PARSE_FILE_INPUT, false);
}
}
#if MICROPY_PY_MICROPYTHON_MEM_INFO