Пример #1
0
void	do_stuff(char *line, char ***e)
{
	int		i;
	char	**split;

	i = 0;
	split = ft_strsplit(line, ' ');
	if (ft_strequ(split[0], "exit"))
	{
		ft_del_tab_char(split);
		ft_strdel(&line);
		exit(0);
	}
	else if (ft_strcmp(split[0], "cd") == 0)
		*e = ft_cd(split, *e);
	else if (ft_strcmp(split[0], "env") == 0)
	{
		if (*e)
			aff_env(*e);
	}
	else if (ft_strcmp(split[0], "setenv") == 0)
		*e = ft_new_env(*e, split[1]);
	else if (ft_strcmp(split[0], "unsetenv") == 0)
		*e = ft_del_env(*e, split[1]);
	else if (split[0])
		ft_check_path(split, *e);
	else
	{
		ft_putstr("zsh: command not found: ");
		ft_putendl(split[0]);
	}
	ft_del_tab_char(split);
}
Пример #2
0
void		ft_read_command(char *buf, t_env *env)
{
	char	*cmd;
	char	*arg;
	char	*path;


	arg = ft_get_cmd(&cmd, buf);
	if (ft_check_bultins(cmd, arg, env))
		exit(EXIT_SUCCESS);
	else if(ft_check_path(cmd, &path, env->path))
		execve(path, cmd, env->env);
	else
		ft_not_found(cmd);
}