Skip to content

Commit

Permalink
Fix executing single builtin command
Browse files Browse the repository at this point in the history
  • Loading branch information
servettonga committed Jul 16, 2024
1 parent c868216 commit 757e7e3
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/minishell.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,6 @@ void free_pipeline(t_pipeline *p);
void interactive_signal_handlers(void);
void non_interactive_signal_handlers(void);

# define PROMPT "(minishell) -> "
# define PROMPT "\033[0;36mminishell\033[0m \033[0;32m> \033[0m"

#endif
3 changes: 1 addition & 2 deletions src/builtin/cmd_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,11 @@ int cmd_exit(t_shell *shell, char **args, t_connection ct)
ft_putstr_fd(": numeric argument required\n", STDERR_FILENO);
shell->exit_status = 255;
}
if (shell->exit_status == EXIT_SUCCESS)
ft_putendl_fd("exit", STDERR_FILENO);
if (shell->exit_status < 0)
shell->exit_status = 256 + shell->exit_status;
if (shell->exit_status > 255)
shell->exit_status %= 256;
ft_putendl_fd("exit", STDERR_FILENO);
if (ct == CON_NONE)
cleanup_and_exit_shell(shell);
return (shell->exit_status);
Expand Down
3 changes: 1 addition & 2 deletions src/exec/execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ static pid_t find_type(t_shell *shell, t_pipeline *p, t_pipeline *cur)

static pid_t handle_builtin(t_shell *shell, t_pipeline *p, t_pipeline *cur)
{
if (cur->cmd.connection_type != CON_NONE
&& (cur->cmd.infile != NULL || cur->cmd.outfile != NULL))
if (cur->next == NULL && cur->prev == NULL)
return (execute_builtin(cur->cmd, shell));
else
return (create_child(shell, p, cur));
Expand Down

0 comments on commit 757e7e3

Please sign in to comment.