kopia lustrzana https://github.com/micropython/micropython
ports/unix: Fix building without MICROPY_USE_READLINE.
Signed-off-by: Matthias Urlichs <matthias@urlichs.de>pull/12807/head
rodzic
74003eda2f
commit
139ba10c34
|
@ -320,7 +320,9 @@ STATIC void print_help(char **argv) {
|
|||
"usage: %s [<opts>] [-X <implopt>] [-c <command> | -m <module> | <filename>]\n"
|
||||
"Options:\n"
|
||||
"-h : print this help message\n"
|
||||
#if MICROPY_USE_READLINE == 1
|
||||
"-e : embedded mode: run 'boot.py', enable raw input\n"
|
||||
#endif
|
||||
"-i : enable inspection via REPL after running command/module/file\n"
|
||||
#if MICROPY_DEBUG_PRINTERS
|
||||
"-v : verbose (trace various operations); can be multiple\n"
|
||||
|
@ -624,7 +626,9 @@ MP_NOINLINE int main_(int argc, char **argv) {
|
|||
const int NOTHING_EXECUTED = -2;
|
||||
int ret = NOTHING_EXECUTED;
|
||||
bool inspect = false;
|
||||
#if MICROPY_USE_READLINE == 1
|
||||
bool embed = false;
|
||||
#endif
|
||||
for (int a = 1; a < argc; a++) {
|
||||
if (argv[a][0] == '-') {
|
||||
if (strcmp(argv[a], "-i") == 0) {
|
||||
|
@ -637,9 +641,11 @@ MP_NOINLINE int main_(int argc, char **argv) {
|
|||
set_sys_argv(argv, argc, a + 2); // Then what comes after the command
|
||||
ret = do_str(argv[a + 1]);
|
||||
break;
|
||||
#if MICROPY_USE_READLINE == 1
|
||||
} else if (strcmp(argv[a], "-e") == 0) {
|
||||
embed = true;
|
||||
pyexec_file_if_exists("boot.py");
|
||||
#endif
|
||||
} else if (strcmp(argv[a], "-m") == 0) {
|
||||
if (a + 1 >= argc) {
|
||||
return invalid_args();
|
||||
|
@ -735,6 +741,7 @@ MP_NOINLINE int main_(int argc, char **argv) {
|
|||
inspect = true;
|
||||
}
|
||||
if (ret == NOTHING_EXECUTED || inspect) {
|
||||
#if MICROPY_USE_READLINE == 1
|
||||
if (embed) {
|
||||
// Run main.py if not told otherwise
|
||||
if (ret == NOTHING_EXECUTED) {
|
||||
|
@ -755,7 +762,9 @@ MP_NOINLINE int main_(int argc, char **argv) {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if (isatty(0) || inspect) {
|
||||
} else
|
||||
#endif
|
||||
if (isatty(0) || inspect) {
|
||||
prompt_read_history();
|
||||
ret = do_repl();
|
||||
prompt_write_history();
|
||||
|
|
Ładowanie…
Reference in New Issue