Example #1
0
void		ft_create_builtin(t_term *term)
{
	char	*tmp;
	int		i;

	i = 0;
	tmp = NULL;
	if (ft_strcmp(term->cmds[0], "cd") == 0)
		ft_cd(term);
	else if (ft_strcmp(term->cmds[0], "env") == 0)
		(!term->cmds[1]) ? ft_display_env(term) : ft_env_options(term);
	else if (ft_strcmp(term->cmds[0], "setenv") == 0)
		ft_process_setenv(term, term->cmds[1], term->cmds[2]);
	else if (ft_strcmp(term->cmds[0], "unsetenv") == 0)
		ft_process_unsetenv(term, term->cmds[1]);
	else if (ft_strcmp(term->cmds[0], "exit") == 0)
	{
		reset_shell();
		ft_putendl("Exiting shell");
		if (term->cmds[1])
			i = ft_atoi(term->cmds[1]);
		ft_free_struct(term);
		exit(i);
	}
	term->i = 0;
	term->u = NULL;
}
Example #2
0
int	ft_check(char *line, char **nenv)
{
	ft_skip(&line);
	if (*line == '\0')
		return (1);
	if (ft_strncmp(line, "exit", 3) == 0)
		exit(0);
	if (ft_strncmp(line, "env", 3) == 0)
	{
		ft_display_env(nenv);
		return (1);
	}
<<<<<<< HEAD