Skip to content

Commit

Permalink
fix redirection
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmytro Moroz committed Jul 27, 2024
1 parent 5f8d7c1 commit f7be58b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/parser/set_redirections.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
/* ::: :::::::: */
/* set_redirections.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sehosaf <sehosaf@student.42warsaw.pl> +#+ +:+ +#+ */
/* By: dmoroz <dmoroz@student.42warsaw.pl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/10 20:28:38 by sehosaf #+# #+# */
/* Updated: 2024/07/18 21:39:45 by sehosaf ### ########.fr */
/* Updated: 2024/07/27 13:29:39 by dmoroz ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -36,7 +36,7 @@ int set_redirections(t_pipeline *node)
res = set_redir(node, i, &node->cmd.infile, 1);
}
else if (node->cmd.args[i][0] == '>')
res = set_redir(node, i, &node->cmd.outfile, 1 + node->cmd.ap_mode);
res = set_redir(node, i, &node->cmd.outfile, 1);
else
i++;
if (res)
Expand All @@ -49,17 +49,17 @@ static int set_redir(t_pipeline *nd, int i, char **s_field, int ck_char)
{
char *arg;

if (!nd->cmd.args[i + 1])
if (nd->cmd.args[i][1] == '<')
nd->cmd.is_heredoc = 1;
if (nd->cmd.args[i][1] == '>')
nd->cmd.ap_mode = ck_char++;
if (!nd->cmd.args[i + 1] && !nd->cmd.args[i][ck_char])
{
ft_putstr_fd(ERR_SNX_TOKEN, STDERR_FILENO);
ft_putstr_fd(nd->cmd.args[i], STDERR_FILENO);
ft_putendl_fd("`", STDERR_FILENO);
return (1);
}
if (nd->cmd.args[i][1] == '<')
nd->cmd.is_heredoc = 1;
if (nd->cmd.args[i][1] == '>')
nd->cmd.ap_mode = 1;
arg = nd->cmd.args[i];
if (arg[ck_char] == 0)
{
Expand Down

0 comments on commit f7be58b

Please sign in to comment.