diff --git a/minishell.c b/minishell.c index 3e52b38..09383ba 100755 --- a/minishell.c +++ b/minishell.c @@ -6,7 +6,7 @@ /* By: mea +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/05/02 12:14:09 by narnaud #+# #+# */ -/* Updated: 2022/05/18 15:50:52 by narnaud@stude ### ########.fr */ +/* Updated: 2022/05/24 08:23:21 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ @@ -77,8 +77,7 @@ int main(int argc, char **argv, char **envp) static t_datas datas; static int i = 0; - datas.silent = argc > 1; - (void)argc; + datas.silent = (argc > 2 && !ft_strncmp(argv[1], "-c", 3)); datas.envp = ft_calloc(ENVP_MAX_SIZE, sizeof(char *)); while (*envp) datas.envp[i++] = ft_strdup(*(envp++)); @@ -87,14 +86,7 @@ int main(int argc, char **argv, char **envp) getcwd(NULL, 0)); datas.exit_code = 0; if (datas.silent) - { - i = 1; - while (i < argc) - { - prompt(&datas, argv[i]); - i++; - } - } + prompt(&datas, argv[2]); else while (1) prompt(&datas, NULL); diff --git a/parser.c b/parser.c index af309df..e0f90a0 100755 --- a/parser.c +++ b/parser.c @@ -6,7 +6,7 @@ /* By: mea +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/05/02 16:09:25 by narnaud #+# #+# */ -/* Updated: 2022/05/18 14:58:51 by narnaud@stude ### ########.fr */ +/* Updated: 2022/05/24 08:25:06 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ @@ -54,7 +54,7 @@ static size_t count_arguments(t_token *tok) if (tok->type == WORD) ret++; if (tok->value[0] == '(') - ret++; + ret += 2; tok = tok->next; } return (ret); @@ -69,6 +69,7 @@ static t_token *parse_cmd(t_datas *datas, t_token *tok, t_command *cmd) if (tok->value[0] == '(') { cmd->argv[cmd->argc++] = get_var_value(datas, "MINISH", 7); + cmd->argv[cmd->argc++] = ft_strdup("-c"); cmd->argv[cmd->argc++] = ft_substr(tok->value, 1, ft_strlen(tok->value) - 2); } diff --git a/utils.c b/utils.c index 46674ce..1f259e1 100644 --- a/utils.c +++ b/utils.c @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* utils_1.c :+: :+: :+: */ +/* utils.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: mea +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/05/03 08:57:53 by narnaud #+# #+# */ -/* Updated: 2022/05/16 08:18:23 by narnaud ### ########.fr */ +/* Updated: 2022/05/24 08:30:44 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */