」 feat: Parsing of command kinda working

This commit is contained in:
2024-05-30 17:59:49 +02:00
parent d84749d009
commit 6bbdef9d7c
14 changed files with 248 additions and 33 deletions

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/25 15:06:15 by adjoly #+# #+# */
/* Updated: 2024/05/26 16:39:27 by adjoly ### ########.fr */
/* Updated: 2024/05/30 15:47:19 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -19,18 +19,20 @@ t_redirection *__to_redir(char *redir_s)
redir = ft_calloc(sizeof(t_redirection), 1);
redir->sign = __to_redir_sign(redir_s);
if (redir->sign == HEREDOC || redir->sign == OUT_APPEND)
redir->file_name = NULL;
if (redir->sign == OUT_APPEND || redir->sign == HEREDOC)
redir_s += 2;
else
redir_s++;
while (*redir_s && *redir_s == ' ')
redir_s++;
tmp = redir_s;
if (!ft_isalnum(*tmp))
return (redir);
while (*tmp && ft_isalnum(*tmp))
tmp++;
redir->file_name = ft_calloc(tmp - redir_s + 1, sizeof(char));
ft_strlcpy(redir->file_name, redir_s, tmp - redir_s + 1);
if (redir->sign != HEREDOC)
redir_s += (tmp - redir_s);
redir_s += (tmp - redir_s);
return (redir);
}