void loop_42sh(t_shell *sh) { char **cmd; while (1) { loop_prompt(sh); is_to_large_history(sh); cmd = lexer(sh->prompt->line, 0); update_history(sh->prompt->line, sh); do_the_thing(sh, &cmd, 0); update_prompt_main_loop(sh); free_tab(cmd); } }
void is_to_large_history(t_shell *sh) { char *line; char **tmp; if (sh->size_hist > 2000) { line = my_strdup("history -c"); tmp = lexer(line, 0); fprintf(stderr, "Your history is to large, he was clear automatically.\n"); do_the_thing(sh, &tmp, 0); free(line); free_tab(tmp); } }
void command_get(t_env *env, char **splitted) { int res; if (!splitted[1]) { ft_putendl("ERROR: you must specify a file to get"); return ; } write_long(env, COMMAND_GET); write_str(env, splitted[1]); if ((res = read_long(env)) == -1) ft_putendl("ERROR: file not found"); else if (res == -2) ft_putendl("ERROR: permissions denied"); else if (res == -3) ft_putendl("ERROR: unknown error"); else do_the_thing(env, splitted); }
void get_std_input(t_shell *sh) { char **cmd; char **instr; char *line; int i; int ret; if (!(line = one_function_get_line(NULL, 1, 0, 0)) || !(instr = my_str_to_wordtab_pattern(line, "\n"))) return ; i = -1; while (instr[++i]) { cmd = lexer(instr[i], 0); ret = replace_exclam_dot(&cmd, sh); update_history(instr[i], sh); if (ret) do_the_thing(sh, &cmd, 0); } free(line); free_tab(instr); }
static void exec_for_if_(char **exec, t_shell *sh) { do_the_thing(sh, &exec, 1); }