heredoc redirection done, looks to work OK
This commit is contained in:
parent
3f984ad498
commit
16cfada91f
5 changed files with 34 additions and 2 deletions
|
|
@ -72,6 +72,7 @@ exec/process_setexec.c\
|
|||
exec/process_setgroup.c\
|
||||
exec/process_setsig.c\
|
||||
exec/redirect_dgreat.c\
|
||||
exec/redirect_dless.c\
|
||||
exec/redirect_great.c\
|
||||
exec/redirect_greatand.c\
|
||||
exec/redirect_less.c\
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ t_redirmap g_redirmap[] =
|
|||
{
|
||||
{TK_LESS, redirect_less},
|
||||
{TK_GREAT, redirect_great},
|
||||
/* {TK_DLESS, redirect_dless}, */
|
||||
{TK_DLESS, redirect_dless},
|
||||
{TK_DGREAT, redirect_dgreat},
|
||||
{TK_LESSAND, redirect_lessand},
|
||||
{TK_GREATAND, redirect_greatand},
|
||||
|
|
|
|||
27
42sh/src/exec/redirect_dless.c
Normal file
27
42sh/src/exec/redirect_dless.c
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* redirect_dless.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/06 22:09:53 by jhalford #+# #+# */
|
||||
/* Updated: 2017/02/07 16:05:09 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "exec.h"
|
||||
|
||||
int redirect_dless(t_redir *redir)
|
||||
{
|
||||
int fds[2];
|
||||
char *str;
|
||||
|
||||
pipe(fds);
|
||||
str = redir->word.word;
|
||||
write(fds[PIPE_WRITE], str, ft_strlen(str));
|
||||
close(fds[PIPE_WRITE]);
|
||||
dup2(fds[PIPE_READ], 0);
|
||||
close(fds[PIPE_READ]);
|
||||
return (0);
|
||||
}
|
||||
|
|
@ -30,6 +30,9 @@ int lexer_dless(t_list **alst, t_lexer *lexer)
|
|||
pop(&lexer->heredoc_stack);
|
||||
while (lexer->str[++lexer->pos])
|
||||
;
|
||||
ft_strappend(&lexer->str, (char[]){'\n', 0});
|
||||
lexer->pos++;
|
||||
return (0);
|
||||
}
|
||||
else
|
||||
while (lexer->str[lexer->pos])
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ int parse_dless(t_btree **ast, t_list **start, t_list **lst)
|
|||
next_tok = (*lst)->next->content;
|
||||
if (next_tok->type != TK_WORD)
|
||||
return (1);
|
||||
node->data.redir.word.word = ft_strdup(next_tok->data);
|
||||
node->data.redir.word.word = ft_strdup(tok->data);
|
||||
node->data.redir.n = 0;
|
||||
ft_lst_delif(start, (*lst)->content, &ft_addrcmp, &token_free);
|
||||
ft_lst_delif(start, (*lst)->next->content, &ft_addrcmp, &token_free);
|
||||
ft_parse(&(*ast)->left, start);
|
||||
|
|
|
|||
Loading…
Reference in a new issue