Skip to content

Commit

Permalink
fix: final fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
magalhaesm committed Jan 21, 2023
1 parent f6f2d7c commit f95214d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 27 deletions.
59 changes: 36 additions & 23 deletions docs/grammar.y
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,41 @@
The Grammar
-------------------------------------------------------
*/
%start commandline
%start list
%%

commandline : list
list : pipeline conditional
conditional : AND pipeline conditional | OR pipeline conditional | ε
pipeline : command fcommand
command : simple_cmd | subshell fsubshell
fcommand : ε | PIPE pipeline
subshell : LBRACE list RBRACE
fsubshell : ε | redirect_list
simple_cmd : WORD fword | cmd_prefix fcmd_prefix
fword : ε | cmd_suffix
fcmd_prefix : ε | WORD fword
cmd_prefix : io_redirect cmd_prefix1
cmd_prefix1 : io_redirect cmd_prefix1 | ε
cmd_suffix : io_redirect cmd_suffix1 | WORD cmd_suffix1
cmd_suffix1 : io_redirect cmd_suffix1 | WORD cmd_suffix1 | ε
redirect_list : io_redirect redirect_list1
redirect_list1 : io_redirect redirect_list1 | ε
io_redirect : io_file | io_here
io_file : LESS WORD | GREAT WORD | DGREAT WORD
io_here : DLESS WORD

list : pipeline conditional
conditional : AND pipeline conditional
| OR pipeline conditional
| empty
pipeline : command pipeline_null
command : simple_cmd
| subshell subshell_redir
pipeline_null : PIPE pipeline
| empty
subshell : LBRACE list RBRACE
subshell_redir : redirect_list
| empty
simple_cmd : WORD word_null
| cmd_prefix fcmd_prefix
word_null : cmd_suffix
| empty
fcmd_prefix : WORD word_null
| empty
cmd_prefix : io_redirect cmd_prefix_null
cmd_prefix_null : io_redirect cmd_prefix_null
| empty
cmd_suffix : io_redirect cmd_suffix_null
| WORD cmd_suffix_null
cmd_suffix_null : io_redirect cmd_suffix_null
| WORD cmd_suffix_null
| empty
redirect_list : io_redirect redirect_list_null
redirect_list_null : io_redirect redirect_list_null
| empty
io_redirect : io_file
| io_here
io_file : LESS WORD
| GREAT WORD
| DGREAT WORD
io_here : DLESS WORD
%%
5 changes: 3 additions & 2 deletions src/exec/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: mdias-ma <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/13 11:46:14 by mdias-ma #+# #+# */
/* Updated: 2023/01/20 21:05:46 by mdias-ma ### ########.fr */
/* Updated: 2023/01/21 18:19:59 by mdias-ma ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -32,6 +32,7 @@ t_bool execute(t_node *root)
save_tree_ref(root);
exec_node(root, &ctx);
reaper(&ctx);
wait_user_signals();
set_exit_status(ctx.retcode);
return (ctx.quit);
}
Expand Down Expand Up @@ -75,7 +76,7 @@ void reaper(t_context *ctx)
ctx->proc--;
it++;
}
if (ctx->error == TRUE)
if (ctx->error == TRUE || ctx->retcode)
return ;
set_wstatus(wstatus, ctx);
}
Expand Down
3 changes: 1 addition & 2 deletions src/exec/exec_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: mdias-ma <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/15 16:35:36 by mdias-ma #+# #+# */
/* Updated: 2023/01/20 17:35:12 by mdias-ma ### ########.fr */
/* Updated: 2023/01/21 18:15:29 by mdias-ma ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -99,7 +99,6 @@ static void spawn_process(char **argv, t_context *ctx)
execve(argv[0], argv, environ);
exit(EXIT_FAILURE);
}
wait_user_signals();
if (ctx->fd[STDIN_FILENO] != STDIN_FILENO)
close(ctx->fd[STDIN_FILENO]);
if (ctx->fd[STDOUT_FILENO] != STDOUT_FILENO)
Expand Down

0 comments on commit f95214d

Please sign in to comment.