summaryrefslogtreecommitdiffstats
path: root/txr.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-09-07 12:31:16 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-09-07 12:31:16 -0700
commitb6a1545715cdef21f6a2989436775e45bada14a9 (patch)
tree0e8857e81c0e783feb310090d488dbeb17fbdc01 /txr.c
parent7cbe71b74d3bd8b8de8f6838934eaaa5365c4e61 (diff)
downloadtxr-b6a1545715cdef21f6a2989436775e45bada14a9.tar.gz
txr-b6a1545715cdef21f6a2989436775e45bada14a9.tar.bz2
txr-b6a1545715cdef21f6a2989436775e45bada14a9.zip
Enter repl after processing options and loading file.
* txr.c (txr_main): i option sets a flag only, processed later in the function.
Diffstat (limited to 'txr.c')
-rw-r--r--txr.c18
1 files changed, 15 insertions, 3 deletions
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;
+ }
}