42sh/src/utils/ast/ast_redir.h
2026-01-19 18:15:57 +00:00

34 lines
861 B
C

#ifndef AST_REDIR_H
#define AST_REDIR_H
#include <stdbool.h>
#include "ast_base.h"
enum ast_redir_type
{
AST_REDIR_TYPE_LESS, // <
AST_REDIR_TYPE_GREAT, // >
AST_REDIR_TYPE_DLESS, // <<
AST_REDIR_TYPE_DGREAT, // >>
AST_REDIR_TYPE_LESSAND, // <&
AST_REDIR_TYPE_GREATAND, // >&
AST_REDIR_TYPE_CLOBBER // >|
};
struct ast_redir
{
struct ast *child;
char *filename;
int io_number; // The FD being redirected (default -1 if not specified,
// implies 0 or 1 based on type)
enum ast_redir_type type;
};
bool ast_is_redir(struct ast *node);
struct ast_redir *ast_get_redir(struct ast *node);
struct ast *ast_create_redir(struct ast *child, char *filename, int io_number,
enum ast_redir_type type);
void ast_free_redir(struct ast_redir *redir);
#endif /* ! AST_REDIR_H */