Example #1
0
int		manage_pre_exec(int idx_cmd, t_group *grp, char *pipe_cmd)
{
	int		ret;

	ret = 0;
	pipe_cmd = NULL;
	get_save_cmd(idx_cmd, grp);
	define_arg_cmd(grp);
	manage_env(grp);
	redir_from(idx_cmd, grp);
	if (grp->exit[1] == false && grp->sh_cmd[idx_cmd + 1] == NULL)
		ret = redir_to(idx_cmd, grp);
	return (ret);
}
Example #2
0
unsigned char	main_loop(char *av[], char *envp[])
{
	int			ret[2];
	char		*choice;
	t_all		*all;
	long long	exit;
	static int	run = 0;

	init(ret, &choice, &envp, &all);
	init_2(&exit);
	while (ret[1] != 0 && (!choice || exit == -2))
	{
		prompt(ret[0]);
		ft_strdel(&choice);
		ret[1] = get_next_line(0, &choice);
		all = make_all(ft_strdup(choice), av, envp);
		(CL_SCR) ? cl_screen(all) : 0;
		(!IS_EXIT && !CL_SCR) ? (ret[0] = manage_choice(all)) : 0;
		manage_env(&all, &envp, &run, &exit);
	}
	prepare_exit(&envp, &all, &choice, ret[1]);
	exit = (exit == -2 || exit == -1) ? 0 : exit;
	return ((unsigned char)exit);
}