55 lines
1.5 KiB
C
55 lines
1.5 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* main.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2019/09/19 17:08:46 by tmaze #+# #+# */
|
|
/* Updated: 2019/09/20 11:58:04 by tmaze ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "minishell.h"
|
|
|
|
void put_env(t_list *env)
|
|
{
|
|
t_list *it;
|
|
|
|
it = env;
|
|
while (it)
|
|
{
|
|
ft_printf("%s=", ((char**)it->content)[0]);
|
|
if (((char**)it->content)[1])
|
|
ft_printf("%s", ((char**)it->content)[1]);
|
|
ft_putchar('\n');
|
|
it = it->next;
|
|
}
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
extern char **environ;
|
|
t_list *env;
|
|
char *cmd;
|
|
|
|
env = NULL;
|
|
if ((env = env2lst(environ)) == NULL)
|
|
return (2);
|
|
while (1)
|
|
{
|
|
cmd = NULL;
|
|
ft_printf("%s$>%s ", FT_COLOR_GREEN, FT_RESET);
|
|
if (ft_getline(&cmd) >= 0)
|
|
{
|
|
ft_printf("%s\n", cmd);
|
|
if (ft_strequ(cmd, "env"))
|
|
put_env(env);
|
|
}
|
|
ft_strdel(&cmd);
|
|
break ;
|
|
}
|
|
ft_lstdel(&env, &lstdelenvelem);
|
|
return (0);
|
|
}
|