From e402f9dcad7962dc4dc474d46fde4c8d1090bb50 Mon Sep 17 00:00:00 2001 From: starnakin Date: Fri, 30 Jun 2023 15:34:51 +0200 Subject: [PATCH] fix: builtin strdup the executable --- src/exec/exec.c | 4 ++-- src/input/input.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/exec/exec.c b/src/exec/exec.c index a604891..a05a6d8 100644 --- a/src/exec/exec.c +++ b/src/exec/exec.c @@ -18,10 +18,10 @@ int len(void** list) char* builtin_path(const char* executable) { - if (strcmp(executable, "cd") == 0) - return "cd"; + if (strcmp(executable, "cd") == 0); else return NULL; + return strdup(executable); } int change_directory(char** args, lst** env) diff --git a/src/input/input.c b/src/input/input.c index 6754c80..201475b 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -66,10 +66,10 @@ char *get_user_input(lst** env) if (prompt == NULL) return NULL; input = readline(prompt); - if (input != NULL && str_contain_only(input, "\t ") == 0) - add_history(input); free(prompt); if (input == NULL) printf("exit"); + if (input != NULL && str_contain_only(input, "\t ") == 0) + add_history(input); return (input); }