Esempio n. 1
0
void			builtin_setenv(char ***env, char **cmd)
{
	int		i;
	int		j;
	char	*tmp;

	i = 0;
	if (error_setenv(cmd) == 1)
	{
		cmd[1] = ft_strjoin(cmd[1], "=");
		if (cmd[2] != NULL)
			tmp = ft_strjoin(cmd[1], cmd[2]);
		else
			tmp = ft_strdup(cmd[1]);
		if ((j = search_num_line(env, cmd[1])) != -1)
			(*env)[j] = ft_strdup(tmp);
		else
		{
			*env = ft_tab_dup(*env);
			while ((*env)[i] != NULL)
				i++;
			(*env)[i] = ft_strdup(tmp);
		}
	}
}
Esempio n. 2
0
static void	lauch_execute_backquote(t_cmd *cmd,
	t_env *env, char *newcmd)
{
	t_list		*arg;
	t_env		c_env;
	t_cmd		c_cmd;
	t_dir		c_dir;

	arg = NULL;
	init_copy_env(&c_env, &c_cmd, &c_dir);
	c_cmd.raw = ft_strdup(newcmd);
	c_cmd.split = NULL;
	c_env.var = env_lst_copy(env);
	c_env.nb = env->nb;
	c_cmd.paths = ft_tab_dup(cmd->paths);
	c_cmd.env = env_list_to_array(c_env.var, c_env.nb);
	arg = ft_parser(c_cmd.raw);
	ft_open_close();
	ft_launcher(&arg, &c_cmd, &c_env, &c_dir);
	if (arg)
		ft_free_arg(&arg);
	ft_free_c_env(&c_env, &c_cmd, &c_dir);
	ft_open_close();
}