Exemplo n.º 1
0
int		main(int ac, char **av, char **envp)
{
	char		*line;
	t_tree		*cmd;

	(void)ac;
	(void)av;
	line = NULL;
	g_env = sh_init_env(envp);
	sh_init_winsize(&g_winsize);
	if (!g_env)
		sh_error(1, NULL);
	sh_signal();
	while (sh_prompt(&line))
	{
		if (line && *line)
			cmd = sh_analyze(line);
		if (cmd)
			sh_exec_tree(cmd);
		if (line && line[0] != '\0')
			sh_deltree(&cmd);
		ft_strdel(&line);
	}
	return (1);
}
Exemplo n.º 2
0
int			main(int argc, const char **argv)
{
	t_sh_env		env;
	int				error;
	t_ckbt			*tree;
	t_cks			line;

	if (sh_init_env(&env, argc, argv) == 0)
	{
		g_sh_env = &env;
		while ((sh_prompt(&env), (line = cks_get_line(0))) != NULL)
		{
			tree = ckbt_new(t_sh_command);
			error = sh_parse(line, tree);
			if (!error)
				sh_exec(&env, tree);
			else
				printf("42sh: syntax error\n");
			cks_free(line);
		}
	}
	return (0);
}