fix: builtin strdup the executable

This commit is contained in:
starnakin 2023-06-30 15:34:51 +02:00
parent db184b4aee
commit e402f9dcad
2 changed files with 4 additions and 4 deletions

View File

@ -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)

View File

@ -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);
}