From 1b8967ea87c63342f03c340d44a084ea7f62cae9 Mon Sep 17 00:00:00 2001 From: iceyrazor Date: Sat, 28 Feb 2026 23:49:02 -0600 Subject: command typing now can chain commands with just ; --- src/main.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 3b2db6e..ef42a50 100755 --- a/src/main.c +++ b/src/main.c @@ -2,19 +2,16 @@ #include #include +#include "main.h" #include "helper_functions.c" #include "lsh_main_func.c" +#include "lsh_split_line.c" #include "lsh_builtins.c" -typedef struct{ - char *prompt; - char *pre_prompt; -} SHELL_OB; - -void lsh_loop(SHELL_OB *shell_obj) -{ +void lsh_loop(SHELL_OB *shell_obj){ char *line; char **args; + CMD **cmds; int status; do { @@ -25,14 +22,22 @@ void lsh_loop(SHELL_OB *shell_obj) free(pwd); printf("%s",shell_obj->prompt); line = lsh_read_line(); - args = lsh_split_line(line); - status = lsh_execute(args); + cmds = lsh_split_command(line); + int j=0; + while (cmds[j]){ + args = lsh_split_line(cmds[j]->cmd); + status = lsh_execute(args); + free(cmds[j]); + j++; + + int i=0; + while (args[i]) + free(args[i++]); + free(args); + } + free(cmds); free(line); - int i=0; - while (args[i]) - free(args[i++]); - free(args); } while (status); } -- cgit v1.3