work
This commit is contained in:
26
builtin/env.c
Normal file
26
builtin/env.c
Normal file
@ -0,0 +1,26 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* env.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/14 14:56:02 by cchauvet #+# #+# */
|
||||
/* Updated: 2023/02/14 14:58:40 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../minishell.h"
|
||||
|
||||
int main(char **env)
|
||||
{
|
||||
t_list **head;
|
||||
t_list *current;
|
||||
|
||||
while (current != NULL)
|
||||
{
|
||||
ft_putendl_fd(1, current->content);
|
||||
current = current->next;
|
||||
}
|
||||
return (0);
|
||||
}
|
40
builtin/export.c
Normal file
40
builtin/export.c
Normal file
@ -0,0 +1,40 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* export.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/14 14:27:08 by cchauvet #+# #+# */
|
||||
/* Updated: 2023/02/14 14:52:50 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../minishell.h"
|
||||
|
||||
int main(char **env)
|
||||
{
|
||||
t_list **env_lst;
|
||||
t_list *current;
|
||||
char *key;
|
||||
char *value;
|
||||
|
||||
env_lst = init_env(env);
|
||||
current = *env_lst;
|
||||
while (current != NULL)
|
||||
{
|
||||
value = ft_strchr(current->content, '=') + 1;
|
||||
key = ft_strndup(current->content,
|
||||
ft_strlen(current->content) - ft_strlen(value));
|
||||
if (key == NULL)
|
||||
{
|
||||
ft_lstclear(env_lst, env_del);
|
||||
return (1);
|
||||
}
|
||||
ft_printf("declare -x %s=\"%s\"\n", key, value);
|
||||
free(key);
|
||||
current = current->next;
|
||||
}
|
||||
ft_lstclear(env_lst, env_del);
|
||||
return (0);
|
||||
}
|
Reference in New Issue
Block a user