aboutsummaryrefslogtreecommitdiff
path: root/src/builtin/unset.c
blob: b1e2d5b27833178e1cb36fdddd86a0a1e52e8b50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   unset.c                                            :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: charles <charles@student.42.fr>            +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/01 17:10:51 by charles           #+#    #+#             */
/*   Updated: 2020/06/17 12:41:45 by nahaddac         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

/*
** \file   unset.c
** \brief  `unset` builtin
*/

#include "minishell.h"

int	builtin_unset(char **argv, t_env env)
{
	size_t	i;

	if (argv[1] == NULL)
		return (1);
	i = 0;
	while (i < env->size)
	{
		if (env_keycmp(env->data[i],argv[1]) == 0)
		{
			ft_vecremove(env, i, free);
			return (0);
		}
		i++;
	}
	return (1);
}