int main(void) { char cmdline[BUFSIZE]; char *argv[BUFSIZE]; char * profile[BUFSIZE]; e_variables=(struct env_var *)malloc(sizeof(struct env_var)*256); // read profile read_profile(profile); // init msh // make the current directory is the home assigned in the profile init_sh(profile); while (1) { // print the prompt which is settled in the profile print_prompt_sign(profile); read_cmdline(cmdline); // the "exit" will break the while loop and exit normally if (strcmp("exit", cmdline) == 0) exit(0); execute(cmdline, argv); } puts("Bye"); return 0; }
int main(int ac, char **argv, char **env) { t_sh *sh; static pid_t pid; (void)ac; (void)argv; if ((init_sh(env, &sh)) == false || sh->env == NULL) return (EXIT_FAILURE); pid = getpid(); my_builtinsinit(sh->env); return (loop_main(sh, pid)); }
int main(int ac, char **av, char **env) { t_token *root; t_parse_tree *tree; t_shell *sh; (void)av; (void)ac; if (!(sh = init_sh(env))) return (FAILURE); parse_config_file(sh); while (!sh->exe->exit && get_line_caps(sh->line) != FAILURE) { pre_parsing(sh); if (!(root = get_tokens(sh->line->line))) return (FAILURE); if ((tree = start_parsing(root, sh)) && (sh->exe->return_value = 2)) exec_cmd(tree, sh->exe); free_tokens(root); XFREE(sh->line->line); } add_in_history_file(sh->line); return (clean_all(sh)); }