diff --git a/include/minishell.h b/include/minishell.h index 00f6cbb..5a675c3 100644 --- a/include/minishell.h +++ b/include/minishell.h @@ -36,7 +36,6 @@ typedef int (*t_builtin_func) (char **); /* ** Builtins */ -int hs_alias(char **args); int hs_cd(char **args); int hs_echo(char **args); int hs_env(char **args); @@ -47,7 +46,6 @@ int hs_exit(char **args); int hs_where(char **args); static char *g_builtins[] = { - "alias", "cd", "echo", "env", @@ -60,7 +58,6 @@ static char *g_builtins[] = { }; static t_builtin_func g_builtin_func[] = { - &hs_alias, &hs_cd, &hs_echo, &hs_env, diff --git a/libft/ft_strdup.c b/libft/ft_strdup.c index 77bf6bb..89807cc 100644 --- a/libft/ft_strdup.c +++ b/libft/ft_strdup.c @@ -23,8 +23,6 @@ char *ft_strdup(const char *src) copy = (char *)malloc(sizeof(char) * (l + 1)); if (copy == 0) return (0); - if (src == NULL) - return (ft_strnew(0)); while (src[i]) { copy[i] = src[i]; diff --git a/src/builtins.c b/src/builtins.c index 305c113..3c17648 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -32,12 +32,6 @@ int hs_echo(char **args) return (0); } -int hs_alias(char **args) -{ - *args = args[0]; - return (0); -} - int hs_help(char **args) { int i; @@ -45,9 +39,9 @@ int hs_help(char **args) *args = args[0]; ft_printf("Existing builtins:\n"); i = 0; - while (i < 9) + while (i < 8) ft_printf("%s, ", g_builtins[i++]); - ft_printf("%s\n", g_builtins[9]); + ft_printf("%s\n", g_builtins[8]); return (0); } diff --git a/src/cd.c b/src/cd.c index 744f514..c0eda0b 100644 --- a/src/cd.c +++ b/src/cd.c @@ -61,7 +61,7 @@ int hs_cd(char **args) char pwd[1024]; int status; - swap = ft_strdup(args[0]); + swap = args[0] == NULL ? ft_strnew(0) : ft_strdup(args[0]); oldpwd = get_env("OLDPWD"); getcwd(currpwd, 1024); status = try_cd(swap, oldpwd); diff --git a/src/commands_execution.c b/src/commands_execution.c index 4950f5b..5d187b3 100644 --- a/src/commands_execution.c +++ b/src/commands_execution.c @@ -17,7 +17,7 @@ int try_builtin(char *builtin, char **args) int i; i = 0; - while (i < 10 && builtin) + while (i < 9 && builtin) { if (ft_strcmp(builtin, g_builtins[i]) == 0) return (g_builtin_func[i](args)); diff --git a/src/environ_utils.c b/src/environ_utils.c index 3932175..f682814 100644 --- a/src/environ_utils.c +++ b/src/environ_utils.c @@ -30,7 +30,7 @@ char *get_env(char *name) if (ABS(ft_strcmp(name, g_environ[i])) == '=') { swap = ft_strsplit(g_environ[i], '='); - dummy = ft_strdup(swap[1]); + dummy = swap[1] == NULL ? ft_strnew(0) : ft_strdup(swap[1]); free_array(swap); break ; }