builtin_exit fixing ariard

also better backslash lexer for sample/subshell_pipe
This commit is contained in:
Jack Halford 2017-03-21 13:50:42 +01:00
parent 930eb5f59a
commit b688c4f544
13 changed files with 26 additions and 15 deletions

View file

@ -6,7 +6,7 @@
# By: wescande <wescande@student.42.fr> +#+ +:+ +#+ # # By: wescande <wescande@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2016/08/29 21:32:58 by wescande #+# #+# # # Created: 2016/08/29 21:32:58 by wescande #+# #+# #
# Updated: 2017/03/21 11:05:18 by gwojda ### ########.fr # # Updated: 2017/03/21 13:38:09 by jhalford ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/15 13:12:06 by jhalford #+# #+# */ /* Created: 2016/11/15 13:12:06 by jhalford #+# #+# */
/* Updated: 2017/03/21 01:17:07 by wescande ### ########.fr */ /* Updated: 2017/03/21 13:16:15 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

10
42sh/sample/subshell_pipe Normal file
View file

@ -0,0 +1,10 @@
echo aaa \
| (echo bbb 1; cat -e ;echo ccc 1) \
| (echo bbb 2; cat -e ;echo ccc 2) \
| (echo bbb 3; cat -e ;echo ccc 3) \
| (echo bbb 4; cat -e ;echo ccc 4) \
| (echo bbb 5; cat -e ;echo ccc 5) \
| (echo bbb 6; cat -e ;echo ccc 6) \
| (echo bbb 7; cat -e ;echo ccc 7) \
| (echo bbb 8; cat -e ;echo ccc 8) \
| (echo bbb 9; cat -e ;echo ccc 9)

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 14:28:41 by jhalford #+# #+# */ /* Created: 2016/11/28 14:28:41 by jhalford #+# #+# */
/* Updated: 2017/03/21 01:44:13 by ariard ### ########.fr */ /* Updated: 2017/03/21 13:50:00 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -32,7 +32,7 @@ int builtin_exit(const char *path, char *const av[], char *const envp[])
data_singleton()->argv[0]); data_singleton()->argv[0]);
return (0); return (0);
} }
if (av[1] && !ft_stris(av[1], ft_isdigit)) if (av && av[1] && !ft_stris(av[1], ft_isdigit))
error_msg(EXITERR_0); error_msg(EXITERR_0);
status = (av && av[1]) ? status = (av && av[1]) ?
ft_atoi(av[1]) : ft_atoi(ft_getenv(data_singleton()->env, "?")); ft_atoi(av[1]) : ft_atoi(ft_getenv(data_singleton()->env, "?"));

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 15:47:30 by wescande #+# #+# */ /* Created: 2017/03/07 15:47:30 by wescande #+# #+# */
/* Updated: 2017/03/21 01:21:04 by wescande ### ########.fr */ /* Updated: 2017/03/21 13:16:25 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/12 12:41:11 by jhalford #+# #+# */ /* Created: 2016/12/12 12:41:11 by jhalford #+# #+# */
/* Updated: 2017/03/20 14:33:51 by jhalford ### ########.fr */ /* Updated: 2017/03/21 13:41:58 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -26,7 +26,7 @@ int mark_process_status(pid_t pid, int status)
else else
{ {
p->state = PROCESS_COMPLETED; p->state = PROCESS_COMPLETED;
if (WIFSIGNALED(status)) if (WIFSIGNALED(status) && WTERMSIG(status) != SIGPIPE)
ft_dprintf(2, "%s\n", strsignal((WTERMSIG(status)))); ft_dprintf(2, "%s\n", strsignal((WTERMSIG(status))));
} }
return (0); return (0);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/09 14:51:23 by jhalford #+# #+# */ /* Created: 2017/03/09 14:51:23 by jhalford #+# #+# */
/* Updated: 2017/03/20 20:25:06 by jhalford ### ########.fr */ /* Updated: 2017/03/21 13:16:20 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/17 11:37:47 by gwojda #+# #+# */ /* Created: 2016/12/17 11:37:47 by gwojda #+# #+# */
/* Updated: 2017/03/20 21:25:22 by jhalford ### ########.fr */ /* Updated: 2017/03/21 13:37:25 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/03 11:56:49 by jhalford #+# #+# */ /* Created: 2016/12/03 11:56:49 by jhalford #+# #+# */
/* Updated: 2017/03/17 21:01:45 by jhalford ### ########.fr */ /* Updated: 2017/03/21 13:42:01 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -22,6 +22,8 @@ int lexer_backslash(t_list **alst, t_lexer *lexer)
lexer->state = WORD; lexer->state = WORD;
if (lexer->str[lexer->pos] == 0) if (lexer->str[lexer->pos] == 0)
{ {
if (!*token->data)
ft_lst_delif(alst, token, &ft_addrcmp, &token_free);
push(&lexer->stack, BACKSLASH); push(&lexer->stack, BACKSLASH);
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/03 11:58:44 by jhalford #+# #+# */ /* Created: 2016/12/03 11:58:44 by jhalford #+# #+# */
/* Updated: 2017/03/20 15:32:07 by jhalford ### ########.fr */ /* Updated: 2017/03/21 13:33:58 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/05 16:58:24 by jhalford #+# #+# */ /* Created: 2017/03/05 16:58:24 by jhalford #+# #+# */
/* Updated: 2017/03/16 23:17:09 by jhalford ### ########.fr */ /* Updated: 2017/03/21 13:16:57 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/07 18:07:50 by jhalford #+# #+# */ /* Created: 2016/12/07 18:07:50 by jhalford #+# #+# */
/* Updated: 2017/03/20 21:25:25 by jhalford ### ########.fr */ /* Updated: 2017/03/21 13:42:07 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/20 14:45:40 by gwojda #+# #+# */ /* Created: 2017/03/20 14:45:40 by gwojda #+# #+# */
/* Updated: 2017/03/20 23:12:42 by ariard ### ########.fr */ /* Updated: 2017/03/21 13:39:17 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -52,7 +52,6 @@ static int handle_instruction(t_list **token, t_btree **ast)
set_exitstatus(1, 1); set_exitstatus(1, 1);
if (SH_IS_INTERACTIVE(data->opts) && data->lexer.str) if (SH_IS_INTERACTIVE(data->opts) && data->lexer.str)
ft_add_str_in_history(data->lexer.str); ft_add_str_in_history(data->lexer.str);
/* exit(0); */
return (0); return (0);
} }