void shell_run() { shell_running = 1; printf("Vault version %s\n", VAULT_VERSION); printf("Enter \"help\" for list of commands\n"); char *line; while(shell_running) { while ((line = linenoise("vault> ")) != 0) { if (line[0] != '\0') { printf("%s", line); linenoiseHistoryAdd(line); if (line == SHELL_ACTION_HELP) { } if (line == SHELL_ACTION_EXIT) { shell_close(); } } } free(line); } }
int shell_treat_parenthese(t_shell *shell, t_pipe *pipe) { if ((pipe->pid = fork()) == -1) { fprintf(stderr, ERROR_FUNCTION, "fork"); shell_close(shell, EXIT_FAILURE); } else if (pipe->pid == 0) { if (pipe->fd[FD_IN] != -1) shell->fd[FD_IN] = pipe->fd[FD_IN]; if (pipe->fd[FD_OUT] != -1) shell->fd[FD_OUT] = pipe->fd[FD_OUT]; shell_step(shell, strdup(pipe->commands->str)); shell_close(shell, shell->last_return); } return (EXIT_SUCCESS); }