t_bool body(char ***env) { char **t; t_bool b; t = NULL; if ((readline(&t)) == FALSE) return (FALSE); if (t == NULL || t[0] == NULL) return (TRUE); if ((b = builtins(t, env)) == TRUE) { ft_freetstring(&t); return (TRUE); } else if (b == FALSE) { ft_freetstring(&t); return (FALSE); } if (format_and_exec_cmd(t, *env) == TRUE) { ft_freetstring(&t); return (TRUE); } ft_freetstring(&t); return (FALSE); }
static int do_cmd(char **cmd, int *i) { char **tab; int j; int ac; j = -1; if (cmd) while (cmd[++j]) { tab = ft_strsplit3(cmd[j], ' ', '\t', '"'); if (tab && *tab) { ac = cmd_exit(tab, i); if (*i == 2) { ft_freetab(&tab); return (ac); } ac = builtins(tab); if (ac < 0) launch_bin(tab, g_env, 0); } ft_freetab(&tab); } return (0); }
void exec_cmd(char *line, t_env *serv_env) { serv_env->cmd = ft_strsplit(line, ' '); free(line); if ((builtins(serv_env) == 1)) return ; binary(serv_env); }
int shell(int ac, char **av, char **env) { int running; int status; int ret_val; char **argv; char **paths_array; char *abs_path; ac = ac; av = av; running = 1; status = 1; ret_val = 0; while (running) { print_prompt(); argv = get_argv(); /* if no builtins were invoked */ if (builtins(argv, env, &running, &ret_val) == 0) { paths_array = get_patharr(env); abs_path = get_fp(argv[0], paths_array); if (abs_path == NULL) { print_string(argv[0]); print_string(": command not found\n"); } else { free(argv[0]); argv[0] = abs_path; create_subshell(argv, env, &status); } printf("the 'status' of the last executed process is %i\n", status); /* free paths_array after executing command */ free_2Darr(paths_array); } /* free argv pointer and strings inside */ free_2Darr(argv); } return ret_val; /* return any values for success? or error? */ }