예제 #1
0
파일: env.c 프로젝트: lleverge/Minishell
static void			ft_env_opt(t_env *env, t_env *tmpenv, char **cmd)
{
	int		i;
	int		j;

	i = 0;
	j = 0;
	while (cmd[1][++i])
		if (cmd[1][i] != 'u' && cmd[1][i] != 'i')
		{
			ft_bad_opt(cmd[1][i]);
			return ;
		}
	while (cmd[1][++j])
	{
		if (cmd[1][j] == 'u')
		{
			ft_env_u(env, cmd);
			return ;
		}
		else if (cmd[1][j] == 'i')
		{
			ft_env_i(tmpenv, cmd);
			return ;
		}
	}
}
예제 #2
0
static int		check(char **command, t_opt *opt)
{
	int			i;

	if ((i = ft_env_check_opt(command, opt, 1, 0)) == -1)
		return (-1);
	if ((i = ft_env_check_opt_plus(command, opt, i)) == -1)
		return (-1);
	if (opt->u && ft_env_u(opt) == -1)
		return (-1);
	if (opt->i)
		ft_env_i(opt);
	if (opt->extra)
		ft_env_extra(opt);
	if (opt->p && ft_env_p(opt, &command[i]) == -1)
		return (-1);
	return (i);
}
예제 #3
0
파일: last2.c 프로젝트: smurfy92/42-21sh
void		ft_father(t_term *term)
{
	char	*tmp;
	int		y;

	tmp = NULL;
	dup2(term->pipe[1], STDOUT_FILENO);
	close(term->pipe[0]);
	(y = -1) ? ft_check_cmds(term) : 0;
	(term->i) ? ft_env_i(term) : 0;
	while (term->cmds[++y])
		(ft_strcmp(term->cmds[y], term->path) == 0) ?\
		term->cmds = &term->cmds[y] : 0;
	y = 0;
	(!term->cmds[1]) ? (tmp = term->cmds[0]) : 0;
	while (term->cmds[++y])
	{
		(!tmp) ? (tmp = ft_strdup(term->cmds[y - 1])) : 0;
		tmp = ft_strjoin(ft_strjoin(tmp, " "), term->cmds[y]);
	}
	execve(term->path, term->cmds, term->env);
	term->path = NULL;
}