MiniDevil
As beautiful as a shell
Heredoc collection (pre processes all heredocs in AST) More...
Include dependency graph for heredoc_collect.c:Heredoc collection (pre processes all heredocs in AST)
Definition in file heredoc_collect.c.
Functions | |
| static int | collect_one (t_ast *node, t_shell *shell) |
| Collect a single heredoc content into a pipe fd. More... | |
| static int | walk_redir (t_ast *node, t_shell *shell) |
| Process a redirection node (and collecting heredoc if applicable) More... | |
| static void | close_heredoc_fds (t_ast *node) |
| Recursively close cached heredoc file descriptors in the AST. More... | |
| int | walk_heredocs (t_ast *node, t_shell *shell) |
| Recursively walk the AST collecting all heredocs. More... | |
| int | collect_heredocs (t_ast *node, t_shell *shell) |
| Pre collect all heredocs in the AST before the execution phase. More... | |
Collect a single heredoc content into a pipe fd.
Calls handle_heredoc() to read the input and stores the result in the node's heredoc_fd variable for later use during execution
| node | Heredoc redirection node (heredoc_fd is set on success) |
| shell | Shell context |
Definition at line 26 of file heredoc_collect.c.
References t_ast::data, t_redir_node::file, handle_heredoc(), t_redir_node::heredoc_fd, t_redir_node::quote, and t_ast_data::redir.
Referenced by walk_redir().
Here is the call graph for this function:
Here is the caller graph for this function:Process a redirection node (and collecting heredoc if applicable)
If the node is a heredoc, it collects its content, then recursively walks into the inner command node to find more redirections
| node | Redirection AST node |
| shell | Shell context |
Definition at line 47 of file heredoc_collect.c.
References t_redir_node::cmd, collect_one(), t_ast::data, NODE_REDIR_HEREDOC, t_ast_data::redir, t_ast::type, and walk_heredocs().
Referenced by walk_heredocs().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Recursively close cached heredoc file descriptors in the AST.
| node | Root of the AST subtree |
Definition at line 64 of file heredoc_collect.c.
References t_ast_data::binary, t_redir_node::cmd, t_ast::data, t_redir_node::heredoc_fd, t_binary_node::left, NODE_PIPE, NODE_REDIR_HEREDOC, NODE_REDIR_IN, t_ast_data::redir, t_binary_node::right, and t_ast::type.
Referenced by collect_heredocs().
Here is the caller graph for this function:Recursively walk the AST collecting all heredocs.
It traverses the pipe & redirection nodes first to ensure all heredoc prompts appear before any command runs
| node | Root of the AST Subtree |
| shell | Shell context |
Definition at line 95 of file heredoc_collect.c.
References t_ast_data::binary, t_ast::data, t_binary_node::left, NODE_PIPE, NODE_REDIR_HEREDOC, NODE_REDIR_IN, t_binary_node::right, t_ast::type, and walk_redir().
Referenced by collect_heredocs(), and walk_redir().
Here is the call graph for this function:
Here is the caller graph for this function:Pre collect all heredocs in the AST before the execution phase.
Walks the entire AST to read all heredoc inputs first. On failure it closes any previously collected heredocs fds to prevent leaks
| node | Root of the AST |
| shell | Shell context |
Definition at line 120 of file heredoc_collect.c.
References close_heredoc_fds(), and walk_heredocs().
Referenced by process_input(), and process_ui_input().
Here is the call graph for this function:
Here is the caller graph for this function: