36 lines
1.3 KiB
C
36 lines
1.3 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* unset.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2023/02/22 13:28:27 by erey-bet #+# #+# */
|
|
/* Updated: 2023/04/07 12:46:28 by erey-bet ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "./builtins_private.h"
|
|
|
|
int error(char *str, int fd)
|
|
{
|
|
write(fd, "bozoshell: unset: `", 19);
|
|
write(fd, str, ft_strlen(str));
|
|
write(fd, "': not a valid identifier\n", 26);
|
|
return (1);
|
|
}
|
|
|
|
int unset(t_list **env, char **args, int fd)
|
|
{
|
|
int i;
|
|
int err;
|
|
|
|
i = -1;
|
|
err = 0;
|
|
while (args[++i])
|
|
if (delete_by_key(args[i], env))
|
|
if (!possible_key(args[i]))
|
|
err = error(args[i], fd);
|
|
return (err);
|
|
}
|