diff --git a/built-in.c b/built-in.c index 46e9861..95504e8 100755 --- a/built-in.c +++ b/built-in.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* built-in.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: narnaud +#+ +:+ +#+ */ +/* By: mea +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/01/06 09:02:57 by narnaud #+# #+# */ -/* Updated: 2022/05/16 09:17:34 by narnaud ### ########.fr */ +/* Updated: 2022/05/16 10:44:36 by mea ### ########.fr */ /* */ /* ************************************************************************** */ @@ -94,7 +94,7 @@ int ft_cd(t_command *cmd) int ft_exit(t_datas *datas, t_command *cmd) { - if (cmd->argc > 1) + if (cmd->argc < 2) halt(datas, EXIT_SUCCESS, 0); else halt(datas, ft_atoi(cmd->argv[1]), 0); diff --git a/caller.c b/caller.c index 375e00b..d219c39 100755 --- a/caller.c +++ b/caller.c @@ -6,7 +6,7 @@ /* By: mea +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/05/03 11:48:16 by narnaud #+# #+# */ -/* Updated: 2022/05/16 08:12:12 by narnaud ### ########.fr */ +/* Updated: 2022/05/16 10:42:40 by mea ### ########.fr */ /* */ /* ************************************************************************** */ @@ -28,7 +28,7 @@ int call_builtin(t_datas *datas, t_command *cmd) else if (ft_strncmp(cmd->argv[0], "unset", 6) == 0) return (ft_unset(datas, cmd)); else if (ft_strncmp(cmd->argv[0], "env", 4) == 0) - return (ft_env(datas, cmd)); + return (ft_env(datas, cmd, 0)); else if (ft_strncmp(cmd->argv[0], "exit", 5) == 0) return (ft_exit(datas, cmd)); else diff --git a/env.c b/env.c index 3a6f115..404cb5f 100755 --- a/env.c +++ b/env.c @@ -6,7 +6,7 @@ /* By: mea +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/02/16 09:41:29 by narnaud #+# #+# */ -/* Updated: 2022/05/12 14:32:41 by mea ### ########.fr */ +/* Updated: 2022/05/16 10:43:01 by mea ### ########.fr */ /* */ /* ************************************************************************** */ @@ -42,7 +42,7 @@ int ft_unset(t_datas *datas, t_command *cmd) return (0); } -int ft_env(t_datas *datas, t_command *cmd) +int ft_env(t_datas *datas, t_command *cmd, int declared_pop) { int i; int fd_out; @@ -54,6 +54,8 @@ int ft_env(t_datas *datas, t_command *cmd) i = 0; while (datas->envp[i]) { + if (declared_pop) + ft_putstr_fd("declare -x ", fd_out); ft_putstr_fd(datas->envp[i], fd_out); ft_putchar_fd('\n', fd_out); i++; @@ -69,7 +71,7 @@ int ft_export(t_datas *datas, t_command *cmd) int i; i = 0; - if (cmd->argc < 2) + if (cmd->argc < 2 && (ft_env(datas, cmd, 1), 1)) return (0); new = ft_split(cmd->argv[1], '='); name_len = ft_strlen(new[0]); diff --git a/minishell.h b/minishell.h index 09ac1b4..19d2ded 100755 --- a/minishell.h +++ b/minishell.h @@ -6,7 +6,7 @@ /* By: mea +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/05/02 13:50:44 by narnaud #+# #+# */ -/* Updated: 2022/05/16 10:23:25 by mea ### ########.fr */ +/* Updated: 2022/05/16 10:42:18 by mea ### ########.fr */ /* */ /* ************************************************************************** */ @@ -76,7 +76,7 @@ int ft_exit(t_datas *datas, t_command *cmd); // ----------------------------------Env.c int ft_unset(t_datas *datas, t_command *cmd); -int ft_env(t_datas *datas, t_command *cmd); +int ft_env(t_datas *datas, t_command *cmd, int declared_pop); int ft_export(t_datas *datas, t_command *cmd); // ----------------------------------Caller.c