diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-23 19:55:54 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-23 19:55:54 +0200 |
commit | 026cb9bf7c4c80b34ecabab27409681be7c17a41 (patch) | |
tree | 420ba377ce417b0c78f5d74d093900e8dd6faacb /src | |
parent | C'est pas bon ca (diff) | |
download | 42-minishell-026cb9bf7c4c80b34ecabab27409681be7c17a41.tar.gz 42-minishell-026cb9bf7c4c80b34ecabab27409681be7c17a41.tar.bz2 42-minishell-026cb9bf7c4c80b34ecabab27409681be7c17a41.tar.xz 42-minishell-026cb9bf7c4c80b34ecabab27409681be7c17a41.tar.zst 42-minishell-026cb9bf7c4c80b34ecabab27409681be7c17a41.zip |
y a du taff
Diffstat (limited to '')
-rw-r--r-- | src/ft_e_builtins.c | 2 | ||||
-rw-r--r-- | src/ft_e_externs.c | 4 | ||||
-rw-r--r-- | src/ft_s_lcom.c | 14 | ||||
-rw-r--r-- | src/ft_s_struct.h | 2 |
4 files changed, 10 insertions, 12 deletions
diff --git a/src/ft_e_builtins.c b/src/ft_e_builtins.c index 57ba28b..d32fbaa 100644 --- a/src/ft_e_builtins.c +++ b/src/ft_e_builtins.c @@ -61,7 +61,7 @@ static void int32_t ret; ft_dup_redirs(ptr, msh); - ret = msh->bu_ptr[bu_id](ptr->args, msh); + ret = msh->bu_ptr[bu_id](ptr->argv + 1, msh); ft_lcom_clear(&msh->curr); ft_s_destroy(msh); exit(ret); diff --git a/src/ft_e_externs.c b/src/ft_e_externs.c index bf56878..eb8cfed 100644 --- a/src/ft_e_externs.c +++ b/src/ft_e_externs.c @@ -60,10 +60,8 @@ ft_e_extern_child(const char *fullpath, { int32_t ret; - (void)fullpath; - (void)ptr; ft_dup_redirs(ptr, msh); - ret = execve("/bin/ls", argv, NULL); + ret = execve(fullpath, ptr->argv, NULL); /* TODO: handle execve failed */ ft_lcom_clear(&msh->curr); ft_s_destroy(msh); diff --git a/src/ft_s_lcom.c b/src/ft_s_lcom.c index 029a5c4..0f6f750 100644 --- a/src/ft_s_lcom.c +++ b/src/ft_s_lcom.c @@ -35,19 +35,19 @@ static int8_t break ; i++; } - if (!((*lcom)->args = (char**)malloc((i + 1) * sizeof(char*)))) + if (!((*lcom)->argv = (char**)malloc((i + 1) * sizeof(char*)))) return (-1); j = 0; while (i > 0 && j < i) { - if (!((*lcom)->args[j] = + if (!((*lcom)->argv[j] = (char*)malloc((ft_strlen(words[j + 1]) + 1) * sizeof(char)))) return (-1); - ft_strlcpy((*lcom)->args[j], words[j + 1], + ft_strlcpy((*lcom)->argv[j], words[j + 1], ft_strlen(words[j + 1]) + 1); j++; } - (*lcom)->args[j] = 0; + (*lcom)->argv[j] = 0; return (0); } @@ -87,8 +87,8 @@ void { renext = tmp->next; ft_memdel((void*)&tmp->com); - if (tmp->args) - ft_delwords(tmp->args); + if (tmp->argv) + ft_delwords(tmp->argv); if (tmp->redir != 0) ft_memdel((void*)&tmp->rdrpath); ft_memdel((void*)&tmp); @@ -107,7 +107,7 @@ t_lcom return (NULL); link->redir = 0; link->com = NULL; - link->args = NULL; + link->argv = NULL; link->rdrpath = NULL; if (ft_get_redir(word, &link) != 0) return (NULL); diff --git a/src/ft_s_struct.h b/src/ft_s_struct.h index cccfaca..6a9b0ad 100644 --- a/src/ft_s_struct.h +++ b/src/ft_s_struct.h @@ -28,7 +28,7 @@ typedef struct s_lcom { char *com; - char **args; + char **argv; int8_t redir; char *rdrpath; struct s_lcom *next; |