From b6a1545715cdef21f6a2989436775e45bada14a9 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 7 Sep 2015 12:31:16 -0700 Subject: Enter repl after processing options and loading file. * txr.c (txr_main): i option sets a flag only, processed later in the function. --- txr.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'txr.c') diff --git a/txr.c b/txr.c index 99304900..c2fef68f 100644 --- a/txr.c +++ b/txr.c @@ -397,6 +397,7 @@ int txr_main(int argc, char **argv) val arg_undo = nil, arg; val parse_stream = std_input; val txr_lisp_p = nil; + val enter_repl = nil; list_collect_decl(arg_list, arg_tail); setvbuf(stderr, 0, _IOLBF, 0); @@ -630,8 +631,8 @@ int txr_main(int argc, char **argv) break; case 'i': #if HAVE_TERMIOS - repl(bindings, std_input, std_output); - return 0; + enter_repl = t; + break; #else format(std_error, lit("~a: option ~a requires a platform with termios\n"), @@ -699,6 +700,8 @@ int txr_main(int argc, char **argv) arg_list = arg_undo; } else { if (!arg) { + if (enter_repl) + goto repl; if (evaled) return EXIT_SUCCESS; hint(); @@ -742,5 +745,14 @@ int txr_main(int argc, char **argv) } } - return read_eval_stream(parse_stream, std_error, t) ? 0 : EXIT_FAILURE; + { + val result = read_eval_stream(parse_stream, std_error, t); + + if (!enter_repl) + return result ? 0 : EXIT_FAILURE; + +repl: + repl(bindings, std_input, std_output); + return 0; + } } -- cgit v1.2.3