From d722c601e8a80279027aa2988dc5fcd371ee9d4d Mon Sep 17 00:00:00 2001 From: Abdellah El Morabit Date: Sun, 2 Feb 2025 20:00:50 +0100 Subject: layout the plans for making the shell, i understand the idea a little better now, i think i implemented an exit function, pretty sure it works decently well, current next thing im going to work on is understanding readline, the autocompletion that comes with it, and trying to list a directory which i have no clue how im going to do --- main.c | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 49b0f0b..c0395e6 100644 --- a/main.c +++ b/main.c @@ -4,6 +4,9 @@ #include #include #include +#include +#include + /* BOOLEANS */ #define true 1 @@ -14,38 +17,30 @@ typedef struct int process_id; } id; -void process_execution(int id) -{ - fork(); -} -void REDIRECTION(); -void SCRIPTING(); - -void ERROR_QUIT(char *CURRENT_COMMAND) -{ - printf("failed %s", CURRENT_COMMAND); - -} - -void err_sys(char *string) +void exit_program(char *argv) { - printf("%s", string); + if (strcmp(argv, "exit")) + { + exit(0); + } } -void PROCESS_PID() +void get_pid_parent_process() { - printf("PID %ld\n", (long)getpid()); } void list_directories() { + } + char *save_variable(char* command, char *argv) { char *variable = (char *)malloc(sizeof(char)); + char *input = readline(); if (strcmp(argv[0], "$") == 0) { @@ -56,7 +51,7 @@ char *save_variable(char* command, char *argv) } } -void ECHO_INPUT(char *command, char *argv) +void echo(char *command, char *argv) { if (strcmp(command, "echo") == 0) { @@ -64,10 +59,9 @@ void ECHO_INPUT(char *command, char *argv) } } -int main(int argc, char *argv[]) { - - int i = getpid(); - printf("%d", i); +int main(int argc, char *argv[]) +{ + return 0; } -- cgit v1.2.3-70-g09d2