working on fixing args count

This commit is contained in:
mdev9
2024-03-04 13:40:41 +01:00
parent e3d93a1262
commit 071331644b
2 changed files with 7 additions and 15 deletions

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */ /* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/07 14:12:49 by tomoron #+# #+# */ /* Created: 2024/02/07 14:12:49 by tomoron #+# #+# */
/* Updated: 2024/03/04 13:00:21 by marde-vr ### ########.fr */ /* Updated: 2024/03/04 13:40:17 by marde-vr ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -132,7 +132,7 @@ int get_args_count(t_cmd *cmds)
if (cur_cmd->type == ARG) if (cur_cmd->type == ARG)
count++; count++;
else else
cur_cmd = cur_cmd->next; cur_cmd = cur_cmd->next->next;
} }
if (cur_cmd->type == ARG) if (cur_cmd->type == ARG)
count++; count++;
@ -294,14 +294,14 @@ char **get_cmd_args(t_msh *msh)
if (!cmd_args || !msh->fds) if (!cmd_args || !msh->fds)
ft_exit(msh, 1); ft_exit(msh, 1);
cur_cmd = msh->cmds; cur_cmd = msh->cmds;
//ft_printf_fd(2, "cmd: %s: args_count: %d\n", cur_cmd->token, args_count); ft_printf_fd(2, "cmd: %s: args_count: %d\n", cur_cmd->token, args_count);
i = 0; i = 0;
while (i < args_count) while (i < args_count)
{ {
if (cur_cmd->type == ARG) if (cur_cmd->type == ARG)
{ {
cmd_args[i] = cur_cmd->token; cmd_args[i] = cur_cmd->token;
//ft_printf_fd(2, "%s[%d] = %s\n", msh->cmds->token, i, cur_cmd->token); ft_printf_fd(2, "%s[%d] = %s\n", msh->cmds->token, i, cur_cmd->token);
i++; i++;
} }
else else
@ -351,17 +351,9 @@ void get_in_type(t_msh *msh, t_cmd *cmds)
{ {
t_cmd *cur_cmd; t_cmd *cur_cmd;
//msh->in_type = ARG;
cur_cmd = cmds; cur_cmd = cmds;
while (cur_cmd && cur_cmd->next && cur_cmd->type == ARG) while (cur_cmd && cur_cmd->next && cur_cmd->type == ARG)
cur_cmd = cur_cmd->next; cur_cmd = cur_cmd->next;
/*
if (!cur_cmd->type)
{
//msh->in_type = ARG;
}
else */
if (cur_cmd->type) if (cur_cmd->type)
{ {
msh->in_type = cur_cmd->type; msh->in_type = cur_cmd->type;
@ -379,7 +371,7 @@ void get_in_type(t_msh *msh, t_cmd *cmds)
{ {
ft_printf_fd(2, "minishell: %s: ", cur_cmd->next->token); ft_printf_fd(2, "minishell: %s: ", cur_cmd->next->token);
perror(""); perror("");
// todo: cancel execution of all commands // todo: cancel execution of all commands????????????????? idk
g_return_code = 1; g_return_code = 1;
} }
} }

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */ /* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/02 21:59:20 by tomoron #+# #+# */ /* Created: 2024/02/02 21:59:20 by tomoron #+# #+# */
/* Updated: 2024/03/04 10:24:54 by marde-vr ### ########.fr */ /* Updated: 2024/03/04 13:39:15 by marde-vr ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -100,7 +100,7 @@ int main(int argc, char **argv, char **envp)
msh->cmds = parse_command(command, msh->env); msh->cmds = parse_command(command, msh->env);
free(command); free(command);
msh->cmds = handle_alias(msh); msh->cmds = handle_alias(msh);
//print_parsed_cmd(msh->cmds); // debug print_parsed_cmd(msh->cmds); // debug
exec_command(msh); exec_command(msh);
free_cmd(msh->cmds); free_cmd(msh->cmds);
} }