diff options
| author | Abdellah El Morabit <nsrddyn@gmail.com> | 2025-02-02 20:00:50 +0100 |
|---|---|---|
| committer | Abdellah El Morabit <nsrddyn@gmail.com> | 2025-02-02 20:00:50 +0100 |
| commit | d722c601e8a80279027aa2988dc5fcd371ee9d4d (patch) | |
| tree | 02afa9472b80a9a2e1b71b686dbcbc58dfc7defa /main.c | |
| parent | cfee09646864f0e9426a1313250b2fe2e5cc4a84 (diff) | |
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
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 38 |
1 files changed, 16 insertions, 22 deletions
@@ -4,6 +4,9 @@ #include <readline/readline.h> #include <dirent.h> #include <unistd.h> +#include <readline/readline.h> +#include <readline/history.h> + /* 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; } |
