aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authoriceyrazor <iceyrazor@mailfence.com>2026-02-28 23:49:02 -0600
committericeyrazor <iceyrazor@mailfence.com>2026-02-28 23:49:02 -0600
commit1b8967ea87c63342f03c340d44a084ea7f62cae9 (patch)
tree06b7998b94fe9b05115d59c2a584339af8943445 /src/main.c
parentbecbecb016f16c2dea64aacd7077973f45ed0517 (diff)
command typing
now can chain commands with just ;
Diffstat (limited to 'src/main.c')
-rwxr-xr-xsrc/main.c31
1 files changed, 18 insertions, 13 deletions
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 <stdlib.h>
#include <unistd.h>
+#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);
}