diff options
Diffstat (limited to 'stage3/shell.c')
-rw-r--r-- | stage3/shell.c | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/stage3/shell.c b/stage3/shell.c index f8d5ada..9cfe833 100644 --- a/stage3/shell.c +++ b/stage3/shell.c @@ -92,7 +92,23 @@ static void cmd_lspci(str arg) static void cmd_run(str arg) { - shell_run_file(arg); + str f = fs_read(arg); + + if (f.data == nil) { + print(S("run: file not found: ")); + print(arg); + print(S("\n")); + } else { + str iter = f; + for (;;) { + str cmd = str_split_walk(&iter, S("\n")); + if (cmd.data == nil) + break; + shell_run_cmd(cmd); + } + + free(f.data); + } } extern char keymap[256]; @@ -149,24 +165,3 @@ void shell_run_cmd(str cmd) print(prog); print(S("\n")); } - -void shell_run_file(str filename) -{ - str f = fs_read(filename); - - if (f.data == nil) { - print(S("shell: file not found: ")); - print(filename); - print(S("\n")); - } else { - str iter = f; - for (;;) { - str cmd = str_split_walk(&iter, S("\n")); - if (cmd.data == nil) - break; - shell_run_cmd(cmd); - } - - free(f.data); - } -} |