summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--a.outbin0 -> 1248 bytes
-rw-r--r--makefile4
-rw-r--r--progs/shel/shel.c26
-rw-r--r--sbin/init/init.c3
5 files changed, 27 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
index 5451a03..e0cc2a9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
 kernel
-
+build
+sbuild
diff --git a/a.out b/a.out
new file mode 100644
index 0000000..5421e76
--- /dev/null
+++ b/a.out
Binary files differdiff --git a/makefile b/makefile
index 990196a..51a756e 100644
--- a/makefile
+++ b/makefile
@@ -16,8 +16,8 @@ all: build_asmlib build_init build_shell build_fdmaker build_devscan
 		if [ -d $$dir ]; then \
 			name=$$(basename $$dir); \
 			echo "Processing $$name $$dir/$$name.c"; \
-			rm build/$$name; \
-			gcc -o ./build/$$name $$dir/$$name.c -z noexecstack -static -march=x86-64; \
+			rm sbuild/$$name; \
+			gcc -o ./sbuild/$$name $$dir/$$name.c -z noexecstack -static -march=x86-64; \
 		fi \
 	done
 
diff --git a/progs/shel/shel.c b/progs/shel/shel.c
index f375250..e3221f4 100644
--- a/progs/shel/shel.c
+++ b/progs/shel/shel.c
@@ -1,34 +1,48 @@
 #include <unistd.h>
 #include <stdlib.h>
+#include <stdio.h>
 #include <sys/wait.h>
 #include <stdbool.h>
 #include <string.h>
 
-void parseInput(char *input, char *command, char *argv) {
+void parseInput(char *input, char *command, char **argv) {
     bool reachedArgv = false;
     char arg[32] = {0};
     int idx = 0;
     int argvIdx = 1;
     
-    for (int i = 0; i < sizeof(input); i++)
+    for (int i = 0; i < strlen(input); i++)
     {
+        char *a = {&(input[i])};
         if (reachedArgv) {
+            if (input[i] == ' ') {
+                arg[idx] = '\0';
+                argv[argvIdx] = strdup(arg);
+                memset(arg, 0, sizeof(arg));
+                argvIdx++;
+                idx = 0;
+                continue;
+            }
             arg[idx] = input[i];
             idx++;
             continue;
         }
         if (input[i] == ' ') {
-            arg[idx] == '\0';
+            arg[idx] = '\0';
             strcpy(command, arg);
             reachedArgv = true;
             memset(arg, 0, sizeof(arg));
-            idx++;
+            idx = 0;
             continue;
         }
         arg[idx] = input[i];
         idx++;
     }
-    
+    argv[0] = command;
+    if (reachedArgv) {
+        arg[idx] = '\0';
+        argv[argvIdx] = strdup(arg);
+    }
 }
 
 int main() {
@@ -38,5 +52,7 @@ int main() {
     char *env[32] = {"PATH=/bin"};
     char path[128] = "/";
 
+    strcpy(input, "/bin/echo meow");
     parseInput(input, command, argv);
+    execve(command, argv, 0);
 }
\ No newline at end of file
diff --git a/sbin/init/init.c b/sbin/init/init.c
index ea64188..9f97918 100644
--- a/sbin/init/init.c
+++ b/sbin/init/init.c
@@ -1 +1,2 @@
-//TODO
\ No newline at end of file
+//TODO
+int main() {return 0;}
\ No newline at end of file