Skip to content

Commit 3d4a535

Browse files
prusnakpfalcon
authored andcommitted
unix: implement -i option (inspect - start REPL after script is finished)
1 parent 5531437 commit 3d4a535

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

unix/main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,9 +474,12 @@ MP_NOINLINE int main_(int argc, char **argv) {
474474

475475
const int NOTHING_EXECUTED = -2;
476476
int ret = NOTHING_EXECUTED;
477+
bool inspect = false;
477478
for (int a = 1; a < argc; a++) {
478479
if (argv[a][0] == '-') {
479-
if (strcmp(argv[a], "-c") == 0) {
480+
if (strcmp(argv[a], "-i") == 0) {
481+
inspect = true;
482+
} else if (strcmp(argv[a], "-c") == 0) {
480483
if (a + 1 >= argc) {
481484
return usage(argv);
482485
}
@@ -556,7 +559,7 @@ MP_NOINLINE int main_(int argc, char **argv) {
556559
}
557560
}
558561

559-
if (ret == NOTHING_EXECUTED) {
562+
if (ret == NOTHING_EXECUTED || inspect) {
560563
if (isatty(0)) {
561564
prompt_read_history();
562565
ret = do_repl();

0 commit comments

Comments
 (0)