diff --git a/codes/builtins/builtin_wrapper.c b/codes/builtins/builtin_wrapper.c index 6f0eb54..368f2bd 100644 --- a/codes/builtins/builtin_wrapper.c +++ b/codes/builtins/builtin_wrapper.c @@ -6,7 +6,7 @@ /* By: kyungjle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/27 06:04:49 by nicknamemoh #+# #+# */ -/* Updated: 2024/04/09 15:07:35 by kyungjle ### ########.fr */ +/* Updated: 2024/04/09 21:04:40 by kyungjle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -49,19 +49,19 @@ t_bool builtin_isbuiltin(char *name) */ t_bool builtin_isbuiltin(char *name) { - if (ft_strncmp(name, "cd", 2) == 0) + if (ft_strlen(name) == 2 && ft_strncmp(name, "cd", 2) == 0) return (TRUE); - else if (ft_strncmp(name, "pwd", 3) == 0) + else if (ft_strlen(name) == 3 && ft_strncmp(name, "pwd", 3) == 0) return (TRUE); - else if (ft_strncmp(name, "echo", 4) == 0) + else if (ft_strlen(name) == 4 && ft_strncmp(name, "echo", 4) == 0) return (TRUE); - else if (ft_strncmp(name, "exit", 4) == 0) + else if (ft_strlen(name) == 5 && ft_strncmp(name, "exit", 4) == 0) return (TRUE); - else if (ft_strncmp(name, "export", 6) == 0) + else if (ft_strlen(name) == 6 && ft_strncmp(name, "export", 6) == 0) return (TRUE); - else if (ft_strncmp(name, "unset", 5) == 0) + else if (ft_strlen(name) == 5 && ft_strncmp(name, "unset", 5) == 0) return (TRUE); - else if (ft_strncmp(name, "env", 3) == 0) + else if (ft_strlen(name) == 3 && ft_strncmp(name, "env", 3) == 0) return (TRUE); return (FALSE); } diff --git a/codes/loader/ldexec_run.c b/codes/loader/ldexec_run.c index 5ae22cc..5d06ac1 100644 --- a/codes/loader/ldexec_run.c +++ b/codes/loader/ldexec_run.c @@ -6,7 +6,7 @@ /* By: kyungjle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/14 01:11:55 by nicknamemoh #+# #+# */ -/* Updated: 2024/04/09 17:46:44 by kyungjle ### ########.fr */ +/* Updated: 2024/04/09 21:13:03 by kyungjle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -37,6 +37,8 @@ pid_t ldexec_run_bin(t_ld_exec exec, pid_t pid) signal(SIGQUIT, SIG_DFL); if (errno != 0) do_exit("ldexec_run_bin.signal"); + if (exec.argv[0][0] == '\0') + exit(EXIT_SUCCESS); if (execve(exec.path, exec.argv, exec.envp) < 0) do_exit("ldexec_run_bin.execve"); } diff --git a/codes/loader/ldpre_ast_redir2.c b/codes/loader/ldpre_ast_redir2.c index 08c3411..dce489e 100644 --- a/codes/loader/ldpre_ast_redir2.c +++ b/codes/loader/ldpre_ast_redir2.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* ldpre_ast_redir2.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: nicknamemohaji +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/04/04 18:41:08 by kyungjle #+# #+# */ -/* Updated: 2024/04/09 20:53:03 by nicknamemoh ### ########.fr */ +/* Updated: 2024/04/09 21:01:10 by kyungjle ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/codes/utils/ld_map_functions2.c b/codes/utils/ld_map_functions2.c index 7795496..1207b6e 100644 --- a/codes/utils/ld_map_functions2.c +++ b/codes/utils/ld_map_functions2.c @@ -79,30 +79,27 @@ char *ldpre_env_fetch(char *key, t_ld_map_env *map) void ldpre_env_add(char *key, char *value, t_ld_map_env *map) { t_ld_map_node *node; - char *key_copy; - char *value_copy; if (!ldpre_env_validate_key(key)) { - printf("syntax error: [%s]\n", key); + printf("export: syntax error: [%s]\n", key); + free(key); + free(value); return ; } ldpre_env_remove(key, map); node = malloc(sizeof(t_ld_map_node) * 1); if (node == NULL) do_exit("ldpre_env_add.malloc"); - key_copy = ft_strdup(key); - value_copy = ft_strdup(value); - if (key_copy == NULL || value_copy == NULL) - do_exit("ldpre_env_add.ft_strdup"); + node->key = ft_strdup(key); + node->value = ft_strdup(value); free(key); free(value); - node->key = key_copy; - node->value = value_copy; node->next = NULL; + if (node->key == NULL || node->value == NULL) + do_exit("ldpre_env_add.ft_strdup"); ld_map_node_attach(map, node); - map->count++; - return ; + map->count += 1; } t_bool ldpre_env_remove(char *key, t_ld_map_env *map)