42-archive/42sh/src/exec/plaunch_for.c

40 lines
1.4 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* plaunch_for.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/15 00:49:20 by wescande #+# #+# */
/* Updated: 2017/03/21 00:51:01 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int plaunch_for(t_process *p)
{
t_ld *temp;
int i;
char **av;
char *var;
temp = p->data.d_for.token;
var = ((char **)temp->content)[0];
if (!word_is_assignment(temp->content))
return (error_badidentifier(var));
temp = temp->next;
while (temp)
{
i = -1;
av = token_to_argv(temp, 1);
while (av[++i])
{
builtin_setenv("setenv", (char*[]){"local", var, av[i], 0},
NULL);
ft_exec(&p->data.d_for.content);
}
temp = temp->next;
}
return (0);
}