16 # include <sys/types.h>
int exec_cmd_not_found(char *cmd)
Print "command not found" to STDERR.
char * find_cmd_path(char *cmd, t_env *env)
Resolve a command name into its full executable path.
int handle_heredoc(char *delimiter, int quoted, t_shell *shell)
Execute a heredoc (read input and return a readable fd)
int setup_redirection(int fd, t_node_type type)
Redirect STDIN or STDOUT to fd, saving the original.
void exec_left_pipe_child(t_ast *left, int pipe_fd[2], t_shell *shell)
Execute the left side of a pipe in a child process.
int open_redir_file(char *file, t_node_type type)
Open a file for redirection (based on the redirection type)
int exec_simple_command(char **args, t_shell *shell)
Execute a simple command (builtin or external)
int handle_redir(t_ast *node, t_shell *shell)
Execute a redirection node.
int exec_builtin(char **args, t_shell *shell)
Dispatch a builtin command to its function.
int executor(t_ast *node, t_shell *shell)
Main AST executor that dispatches by node type.
int walk_heredocs(t_ast *node, t_shell *shell)
Recursively walk the AST collecting all heredocs.
int handle_pipe(t_ast *node, t_shell *shell)
Execute a pipe node by forking left and right children.
int exec_external(char **args, t_shell *shell)
Fork and execute an external command.
int pipe_fork_error(int pipe_fd[2], pid_t left_pid)
Clean up pipe fds and wait for left child on fork failure.
int collect_heredocs(t_ast *node, t_shell *shell)
Pre collect all heredocs in the AST before the execution phase.
void exec_right_pipe_child(t_ast *right, int pipe_fd[2], t_shell *shell)
Execute the right side of a pipe in a child process.
void restore_fd(int saved_fd, t_node_type type)
Restore a previously saved file descriptor.
int is_builtin(char *cmd)
Check if a command is a shell builtin.
char * search_in_dir(char *dir, char *cmd)
Search an executable command in a directory.
Central type definitions for mandatory part.
t_node_type
AST node types.
Environment variable (doubly linked list)