27 ft_putstr_fd(
"minishell: ", STDERR_FILENO);
28 ft_putstr_fd(cmd, STDERR_FILENO);
29 ft_putstr_fd(
": command not found\n", STDERR_FILENO);
43 if (ft_strncmp(cmd,
"echo", 5) == 0)
45 if (ft_strncmp(cmd,
"cd", 3) == 0)
47 if (ft_strncmp(cmd,
"pwd", 4) == 0)
49 if (ft_strncmp(cmd,
"export", 7) == 0)
51 if (ft_strncmp(cmd,
"unset", 6) == 0)
53 if (ft_strncmp(cmd,
"env", 4) == 0)
55 if (ft_strncmp(cmd,
"exit", 5) == 0)
69 if (!args || !args[0])
71 if (ft_strncmp(args[0],
"echo", 5) == 0)
73 if (ft_strncmp(args[0],
"cd", 3) == 0)
75 if (ft_strncmp(args[0],
"pwd", 4) == 0)
77 if (ft_strncmp(args[0],
"export", 7) == 0)
79 if (ft_strncmp(args[0],
"unset", 6) == 0)
81 if (ft_strncmp(args[0],
"env", 4) == 0)
83 if (ft_strncmp(args[0],
"exit", 5) == 0)
97 if (!args || !args[0])
116 waitpid(left_pid, NULL, 0);
117 perror(
"minishell: fork");
int builtin_cd(char **args, t_env **env)
Implement the cd command.
int builtin_echo(char **args)
Implement the echo command.
int builtin_env(char **args, t_env *env)
Implement the env command.
int builtin_exit(char **args, t_shell *shell)
Implement the exit command.
int builtin_export(char **args, t_env **env)
Implement the export command.
int builtin_pwd(void)
Implement the pwd command.
int builtin_unset(char **args, t_env **env)
Implement the unset command.
Shell builtin commands prototypes.
int exec_external(char **args, t_shell *shell)
Fork and execute an external command.
int exec_cmd_not_found(char *cmd)
Print "command not found" to STDERR.
int exec_simple_command(char **args, t_shell *shell)
Execute a simple command (builtin or external)
int exec_builtin(char **args, t_shell *shell)
Dispatch a builtin command to its function.
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 is_builtin(char *cmd)
Check if a command is a shell builtin.
Executor prototypes for commands, pipes, redirections & heredocs.
t_env * env
Environment linked list.