void		ft_unset(char **cmd_line);

환경변수 삭제


static void	delete_env(char **arg)
{
	char	**temp;
	int		i;
	int		j;
	int		cnt;

	i = ft_arrsize(g_envs);
	if (!(temp = (char **)malloc(sizeof(char *) * (i + 1))))
		exit(EXIT_FAILURE);
	i = -1;
	cnt = 0;
	while (g_envs[++i])
	{
		if (!is_there_env(arg, g_envs[i]))
			temp[cnt++] = ft_strdup(g_envs[i]);
		free(g_envs[i]);
		g_envs[i] = NULL;
	}
	temp[cnt] = NULL;
	free(g_envs);
	g_envs = temp;
}

환경변수가 있는지 확인


static int	is_there_env(char **arg, char *env)
{
	int	i;
	int	len;

	i = -1;
	while (arg[++i])
	{
		len = ft_strlen(arg[i]);
		if (strncmp(arg[i], env, len) == 0 &&
				(env[len] == '=' || env[len] == '\\0'))
			return (1);
	}
	return (0);
}