int main() { char *line; char **cmd; uneditedLine = (char*)malloc(256 * sizeof(char)); while (1) { my_setup(); my_prompt(); line = my_read(); strcpy(uneditedLine, line); if (line == 0) return 0; if (line[0] == '\0') { free(line); continue; } cmd = my_parse(line); my_execute(cmd); my_clean(line, cmd); } free(uneditedLine); return 0; }
void my_read(t_sh *sh) { char buf[BUFF_MIN]; int i; int lol; i = 0; my_putstr("\e[0m"); if (sh->cmd) free(sh->cmd); my_prompt(environ, 1, sh->bult->prompt); sh->cmd = xmalloc(sizeof(char) * BUFF_DEF); sh->pipe = 0; while ((lol = xread(STDIN_FILENO, buf, BUFF_MIN)) > 0) { sh->pipe = 0; if (sh->cmd == NULL) sh->cmd = xmalloc(sizeof(char) * BUFF_DEF); buf[lol] = '\0'; if (!check_term_cap(sh, buf, &i)) { if (buf[0] == '\n') { sh->cmd[i] = '\0'; my_putchar('\n'); if (strlen(sh->cmd) >= 1) { sh->cmd = trait_str(sh->cmd); if (!check_synt(sh->cmd)) trait_cmd(sh); } free(sh->cmd); sh->cmd = NULL; i = 0; buf[0] = '\0'; my_prompt(environ, 1, sh->bult->prompt); } else sh->cmd = add_str_end(sh->cmd, buf, &i, 1); } } }
int main(int ac, char **av, char **env) { t_list list; (void)ac; (void)av; g_prompt = NULL; g_prompt = my_prompt(env); if ((signal(SIGINT, ctrl_c)) == SIG_ERR) return (2); if ((recur(env, g_prompt, &list)) == -2) return (2); return (2); }
int main() { char *line; char **cmd; while (1) { my_setup(); my_prompt(); my_read(line); cmd = my_parse(line); //my_execute(cmd); //my_clean(); } return 0; }
int shmain(char **env) { return (my_prompt(env)); }