diff --git a/42sh/Makefile b/42sh/Makefile index 765c032e..0644fd8f 100644 --- a/42sh/Makefile +++ b/42sh/Makefile @@ -33,6 +33,7 @@ SRC_BASE = \ builtin/bt_cd_getpath.c\ builtin/bt_cd_process_dotdot.c\ builtin/bt_cd_process_symlink.c\ +builtin/bt_env_opt.c\ builtin/bt_read_get.c\ builtin/bt_read_term.c\ builtin/builtin_cd.c\ diff --git a/42sh/includes/builtin.h b/42sh/includes/builtin.h index 057430bb..d8894ac3 100644 --- a/42sh/includes/builtin.h +++ b/42sh/includes/builtin.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/14 22:59:57 by jhalford #+# #+# */ -/* Updated: 2017/03/25 16:49:54 by ariard ### ########.fr */ +/* Updated: 2017/03/25 20:40:22 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/builtin/bt_env_opt.c b/42sh/src/builtin/bt_env_opt.c new file mode 100644 index 00000000..b48dfba4 --- /dev/null +++ b/42sh/src/builtin/bt_env_opt.c @@ -0,0 +1,38 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* bt_env_opt.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/25 20:39:54 by jhalford #+# #+# */ +/* Updated: 2017/03/25 20:40:24 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "minishell.h" + +int bt_env_opt_i(char *opt_arg, t_env_data *data) +{ + (void)opt_arg; + ft_tabdel(&data->custom_env); + return (0); +} + +int bt_env_opt_u(char *opt_arg, t_env_data *data) +{ + int i; + char **env; + + if (!(env = data->custom_env)) + return (0); + i = -1; + while (env[++i]) + { + if (ft_strcmp(env[i], opt_arg) == '=' + && ft_strlen(opt_arg) == ft_strlenchr(env[i], '=')) + ft_sstrdel(env, i); + } + return (0); +} + diff --git a/42sh/src/builtin/builtin_env.c b/42sh/src/builtin/builtin_env.c index 4f17fbbf..f2c6284b 100644 --- a/42sh/src/builtin/builtin_env.c +++ b/42sh/src/builtin/builtin_env.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/22 16:20:31 by gwojda #+# #+# */ -/* Updated: 2017/03/25 15:10:52 by jhalford ### ########.fr */ +/* Updated: 2017/03/25 20:40:41 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -23,31 +23,6 @@ static t_cliopts g_env_opts[] = {0, 0, 0, 0, 0, 0}, }; -int bt_env_opt_i(char *opt_arg, t_env_data *data) -{ - (void)opt_arg; - ft_tabdel(&data->custom_env); - return (0); -} - -int bt_env_opt_u(char *opt_arg, t_env_data *data) -{ - DG(); - int i; - char **env; - - if (!(env = data->custom_env)) - return (0); - i = -1; - while (env[++i]) - { - if (ft_strcmp(env[i], opt_arg) == '=' - && ft_strlen(opt_arg) == ft_strlenchr(env[i], '=')) - ft_sstrdel(env, i); - } - return (0); -} - static int bt_env_getcustom(char ***av, t_env_data *data) { if (!av || !*av || !data) diff --git a/42sh/src/main/data_exit.c b/42sh/src/main/data_exit.c index c05439ac..753ea33f 100644 --- a/42sh/src/main/data_exit.c +++ b/42sh/src/main/data_exit.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/07 18:07:50 by jhalford #+# #+# */ -/* Updated: 2017/03/24 15:55:08 by wescande ### ########.fr */ +/* Updated: 2017/03/25 20:27:32 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */