feat(parser): redirections

This commit is contained in:
Matteo Flebus 2026-01-27 19:56:33 +01:00
parent 04ff7376eb
commit 8a5c589742
17 changed files with 78 additions and 108 deletions

View file

@ -14,13 +14,12 @@ struct ast_redir *ast_get_redir(struct ast *node)
return NULL;
}
struct ast *ast_create_redir(struct ast *child, char *filename, int io_number,
struct ast *ast_create_redir(char *filename, int io_number,
enum ast_redir_type type)
{
struct ast_redir *redir = malloc(sizeof(struct ast_redir));
if (!redir)
return NULL;
redir->child = child;
redir->filename =
filename; // Takes ownership? Usually yes in simple ASTs, or dup. Let's
// assume pointer copy for now, but user must manage memory.
@ -34,7 +33,6 @@ void ast_free_redir(struct ast_redir *redir)
{
if (!redir)
return;
ast_free(&redir->child);
free(redir->filename);
free(redir);
}