new Makefile compile libft without relink. change on exec for forker. change on all builtin for return status & set exit status

This commit is contained in:
wescande 2017-03-20 14:42:49 +01:00
parent d2c65880aa
commit 229864750f
16 changed files with 136 additions and 109 deletions

View file

@ -6,14 +6,14 @@
# By: wescande <wescande@student.42.fr> +#+ +:+ +#+ # # By: wescande <wescande@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2016/08/29 21:32:58 by wescande #+# #+# # # Created: 2016/08/29 21:32:58 by wescande #+# #+# #
# Updated: 2017/03/20 11:37:21 by wescande ### ########.fr # # Updated: 2017/03/20 12:04:31 by wescande ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
NAME = 42sh NAME = 42sh
CC = gcc CC = gcc
FLAGS = -Wall -Wextra -Werror -g FLAGS = -Wall -Wextra -Werror -fvisibility=hidden
D_FLAGS = -g D_FLAGS = -g
DELTA = $$(echo "$$(tput cols)-47"|bc) DELTA = $$(echo "$$(tput cols)-47"|bc)
@ -40,6 +40,7 @@ builtin/builtin_hash.c\
builtin/builtin_history.c\ builtin/builtin_history.c\
builtin/builtin_math.c\ builtin/builtin_math.c\
builtin/builtin_read.c\ builtin/builtin_read.c\
builtin/builtin_return_status.c\
builtin/builtin_setenv.c\ builtin/builtin_setenv.c\
builtin/builtin_unset.c\ builtin/builtin_unset.c\
builtin/builtin_unsetenv.c\ builtin/builtin_unsetenv.c\
@ -302,8 +303,8 @@ NB = $(words $(SRC_BASE))
INDEX = 0 INDEX = 0
all : all :
@make -j -C $(LIBFT_DIR) @make -C $(LIBFT_DIR)
@make $(NAME) @make -j $(NAME)
$(NAME): $(LIBFT_LIB) $(OBJ_DIR) $(OBJS) $(NAME): $(LIBFT_LIB) $(OBJ_DIR) $(OBJS)
@$(CC) $(OBJS) -o $(NAME) \ @$(CC) $(OBJS) -o $(NAME) \

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/14 22:59:57 by jhalford #+# #+# */ /* Created: 2017/03/14 22:59:57 by jhalford #+# #+# */
/* Updated: 2017/03/17 18:59:55 by ariard ### ########.fr */ /* Updated: 2017/03/20 12:51:23 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -20,6 +20,7 @@
# define BT_EXPORT_LP (1 << 0) # define BT_EXPORT_LP (1 << 0)
t_execf *is_builtin(t_process *p); t_execf *is_builtin(t_process *p);
int builtin_return_status(int ret, int status);
int builtin_export(const char *path, char *const av[], char *const envp[]); int builtin_export(const char *path, char *const av[], char *const envp[]);
int builtin_unset(const char *path, char *const av[], char *const envp[]); int builtin_unset(const char *path, char *const av[], char *const envp[]);
int builtin_env(const char *path, char *const argv[], char *const envp[]); int builtin_env(const char *path, char *const argv[], char *const envp[]);

View file

@ -6,7 +6,7 @@
# By: jhalford <jack@crans.org> +#+ +:+ +#+ # # By: jhalford <jack@crans.org> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2017/02/07 16:09:36 by jhalford #+# #+# # # Created: 2017/02/07 16:09:36 by jhalford #+# #+# #
# Updated: 2017/03/18 14:15:35 by gwojda ### ########.fr # # Updated: 2017/03/20 12:05:06 by wescande ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
@ -207,7 +207,7 @@ all:
$(NAME): $(OBJ_DIR) $(OBJS) $(NAME): $(OBJ_DIR) $(OBJS)
@$(AR) $(NAME) $(OBJS) @$(AR) $(NAME) $(OBJS)
@ranlib $(NAME) @ranlib $(NAME)
@strip -x $(NAME) @# @strip -x $(NAME)
@printf "\r\033[48;5;15;38;5;25m✅ MAKE $(NAME)\033[0m\033[K\n" @printf "\r\033[48;5;15;38;5;25m✅ MAKE $(NAME)\033[0m\033[K\n"
$(OBJ_DIR)%.o: $(SRC_DIR)%.c | $(OBJ_DIR) $(OBJ_DIR)%.o: $(SRC_DIR)%.c | $(OBJ_DIR)

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/03 11:57:53 by jhalford #+# #+# */ /* Created: 2016/12/03 11:57:53 by jhalford #+# #+# */
/* Updated: 2017/03/16 14:17:57 by jhalford ### ########.fr */ /* Updated: 2017/03/20 12:54:02 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -81,14 +81,14 @@ int builtin_cd(const char *path,
opts = CDOPT_L; opts = CDOPT_L;
i = builtin_cd_opts(av, &opts); i = builtin_cd_opts(av, &opts);
if (!(target = builtin_cd_special(av + i, envp))) if (!(target = builtin_cd_special(av + i, envp)))
return (1); return (builtin_return_status(0, 1));
cwd = getcwd(NULL, 0); cwd = getcwd(NULL, 0);
builtin_setenv(path, (char*[4]){"setenv", "OLDPWD", cwd, NULL}, envp); builtin_setenv(path, (char*[4]){"setenv", "OLDPWD", cwd, NULL}, envp);
free(cwd); free(cwd);
if (chdir(target)) if (chdir(target))
{ {
ft_dprintf(2, CDERR_1, target); ft_dprintf(2, CDERR_1, target);
return (1); return (builtin_return_status(0, 1));
} }
else if (target != av[i]) else if (target != av[i])
ft_printf("%s\n", target); ft_printf("%s\n", target);
@ -97,5 +97,5 @@ int builtin_cd(const char *path,
free(cwd); free(cwd);
if (!ft_strcmp(*(av + i), "-")) if (!ft_strcmp(*(av + i), "-"))
free(target); free(target);
return (0); return (builtin_return_status(0, 0));
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 14:21:41 by jhalford #+# #+# */ /* Created: 2016/11/28 14:21:41 by jhalford #+# #+# */
/* Updated: 2017/01/20 00:10:31 by ariard ### ########.fr */ /* Updated: 2017/03/20 14:40:00 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -25,5 +25,5 @@ int builtin_echo(const char *path, char *const av[], char *const envp[])
ft_putchar(' '); ft_putchar(' ');
} }
ft_putchar('\n'); ft_putchar('\n');
return (0); return (builtin_return_status(0, 0));
} }

View file

@ -6,11 +6,12 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 14:14:20 by jhalford #+# #+# */ /* Created: 2016/11/28 14:14:20 by jhalford #+# #+# */
/* Updated: 2017/03/20 11:29:17 by wescande ### ########.fr */ /* Updated: 2017/03/20 12:52:05 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "minishell.h" #include "minishell.h"
#define US_ENV "env [-i] [-u name] [name=value]... [utility [argument...]]"
static int env_usage(int arg_miss, char c) static int env_usage(int arg_miss, char c)
{ {
@ -18,9 +19,8 @@ static int env_usage(int arg_miss, char c)
ft_dprintf(2, "{red}env: option requires an argument -- u{eoc}\n"); ft_dprintf(2, "{red}env: option requires an argument -- u{eoc}\n");
else if (c) else if (c)
ft_dprintf(2, "{red}env: illegal option -- %c{eoc}\n", c); ft_dprintf(2, "{red}env: illegal option -- %c{eoc}\n", c);
ft_dprintf(2, "usage: env [-i] [-u name] ... [name=value] ... cmd\n"); ft_dprintf(2, "usage: %s\n", US_ENV);
set_exitstatus(1, 1); return (1);
return (0);
} }
static void env_freeone(char **env, char *arg) static void env_freeone(char **env, char *arg)
@ -87,7 +87,8 @@ static int env_treat_flag(char ***custom_env, char *const *arg[])
return (0); return (0);
} }
int builtin_env(const char *path, char *const argv[], char *const envp[]) int builtin_env(const char *path,
char *const argv[], char *const envp[])
{ {
char **env; char **env;
pid_t pid; pid_t pid;
@ -95,12 +96,12 @@ int builtin_env(const char *path, char *const argv[], char *const envp[])
(void)path; (void)path;
pid = 0; pid = 0;
if (!argv || ft_strcmp(*argv, "env")) if (!argv || ft_strcmp(*argv, "env"))
return (env_usage(0, 0)); return (builtin_return_status(0, env_usage(0, 0)));
env = ft_sstrdup((char **)envp); env = ft_sstrdup((char **)envp);
if (env_treat_flag(&env, &argv)) if (env_treat_flag(&env, &argv))
{ {
ft_sstrfree(env); ft_sstrfree(env);
return (0); return (builtin_return_status(0, 1));
} }
if (!*argv) if (!*argv)
{ {
@ -111,6 +112,5 @@ int builtin_env(const char *path, char *const argv[], char *const envp[])
else else
pid = command_setoutput(NULL, argv, env, 0); pid = command_setoutput(NULL, argv, env, 0);
ft_tabdel(&env); ft_tabdel(&env);
set_exitstatus(0, 1); return (builtin_return_status(pid, 0));
return (pid);
} }

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/15 11:39:37 by gwojda #+# #+# */ /* Created: 2017/02/15 11:39:37 by gwojda #+# #+# */
/* Updated: 2017/03/18 11:46:32 by gwojda ### ########.fr */ /* Updated: 2017/03/20 14:01:11 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -47,7 +47,7 @@ int builtin_export(
if (cliopts_get((char**)av, export_opts, &data)) if (cliopts_get((char**)av, export_opts, &data))
ft_perror(); ft_perror();
if (data.flag & BT_EXPORT_LP) if (data.flag & BT_EXPORT_LP)
return (bt_export_print()); return (builtin_return_status(0, bt_export_print()));
av = data.av_data; av = data.av_data;
while (*av) while (*av)
{ {
@ -64,5 +64,5 @@ int builtin_export(
builtin_unsetenv("internal", (char*[]){"local", *av, NULL}, NULL); builtin_unsetenv("internal", (char*[]){"local", *av, NULL}, NULL);
av++; av++;
} }
return (0); return (builtin_return_status(0, 0));
} }

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/18 16:37:43 by gwojda #+# #+# */ /* Created: 2017/02/18 16:37:43 by gwojda #+# #+# */
/* Updated: 2017/02/18 16:51:43 by gwojda ### ########.fr */ /* Updated: 2017/03/20 14:03:30 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -43,8 +43,8 @@ int builtin_hash(const char *path, char *const av[], char *const envp[])
(void)path; (void)path;
(void)envp; (void)envp;
if (ft_hash_opt(av)) if (!av || ft_hash_opt(av))
return (0); return (builtin_return_status(0, 1));
i = 0; i = 0;
while (i < MAX_HASH) while (i < MAX_HASH)
{ {
@ -52,5 +52,5 @@ int builtin_hash(const char *path, char *const av[], char *const envp[])
ft_hash_lst_print(g_hash[i]); ft_hash_lst_print(g_hash[i]);
++i; ++i;
} }
return (0); return (builtin_return_status(0, 0));
} }

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/24 14:54:53 by gwojda #+# #+# */ /* Created: 2017/01/24 14:54:53 by gwojda #+# #+# */
/* Updated: 2017/02/20 20:30:18 by ariard ### ########.fr */ /* Updated: 2017/03/20 14:04:02 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -23,7 +23,7 @@ int builtin_history(const char *path, char *const av[], char *const envp[])
head = data_singleton()->line.list_end; head = data_singleton()->line.list_end;
len = 1; len = 1;
if (!head) if (!head)
return (0); return (builtin_return_status(0, 0));
if (head && !head->str) if (head && !head->str)
head = head->next; head = head->next;
while (head && head->str) while (head && head->str)
@ -34,5 +34,5 @@ int builtin_history(const char *path, char *const av[], char *const envp[])
++len; ++len;
head = head->next; head = head->next;
} }
return (0); return (builtin_return_status(0, 0));
} }

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/17 18:54:00 by ariard #+# #+# */ /* Created: 2017/03/17 18:54:00 by ariard #+# #+# */
/* Updated: 2017/03/17 19:59:42 by ariard ### ########.fr */ /* Updated: 2017/03/20 14:14:59 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -21,11 +21,11 @@
static int error_msg(char *msg) static int error_msg(char *msg)
{ {
ft_dprintf(2, "{red}%s{eoc}", msg); ft_dprintf(2, "{red}%s{eoc}", msg);
return (-1); return (1);
} }
static int init_math(char **var, char **value, char **operator, static int init_math(char **var, char **value, char **operator,
char **operand) char **operand)
{ {
*var = NULL; *var = NULL;
*value = NULL; *value = NULL;
@ -45,71 +45,70 @@ static int get_value(char *var, char **value)
ft_strdel(&esc); ft_strdel(&esc);
if (!ret) if (!ret)
return (error_msg(MATHERR_1)); return (error_msg(MATHERR_1));
temp = ft_sstrstr(data_singleton()->local_var, var); temp = ft_sstrstr(data_singleton()->local_var, var);
if (temp) if (temp)
{ {
temp += ft_strlenchr(temp, '=') + 1; temp += ft_strlenchr(temp, '=') + 1;
*value = ft_strdup(temp); *value = ft_strdup(temp);
if (!(ft_stris(*value, &ft_isdigit))) if (!(ft_stris(*value, &ft_isdigit)))
{ {
ft_strdel(value); ft_strdel(value);
*value = ft_itoa(0); *value = ft_itoa(0);
} }
} }
else else
*value = ft_itoa(0); *value = ft_itoa(0);
return (0); return (0);
} }
static int do_math(char **value, char *operator, char *operand) static int do_math(char **value, char *operator, char *operand)
{ {
long ope1; long ope1;
long ope2; long ope2;
ope1 = ft_atoi(*value); ope1 = ft_atoi(*value);
if (operand) if (operand)
ope2 = ft_atoi(operand); ope2 = ft_atoi(operand);
else else
ope2 = 0; ope2 = 0;
if ((operator[0] == '/' || operator[0] == '%') && ope2 == 0) if ((operator[0] == '/' || operator[0] == '%') && ope2 == 0)
return (error_msg(MATHERR_4)); return (error_msg(MATHERR_4));
else else
{ {
ope1 = (operator[0] == '+') ? ope1 + ope2 : ope1; ope1 = (operator[0] == '+') ? ope1 + ope2 : ope1;
ope1 = (operator[0] == '-') ? ope1 - ope2 : ope1; ope1 = (operator[0] == '-') ? ope1 - ope2 : ope1;
ope1 = (operator[0] == '/') ? ope1 / ope2 : ope1; ope1 = (operator[0] == '/') ? ope1 / ope2 : ope1;
ope1 = (operator[0] == '*') ? ope1 * ope2 : ope1; ope1 = (operator[0] == '*') ? ope1 * ope2 : ope1;
ope1 = (operator[0] == '%') ? ope1 % ope2 : ope1; ope1 = (operator[0] == '%') ? ope1 % ope2 : ope1;
} }
ft_strdel(value); ft_strdel(value);
*value = ft_itoa(ope1); *value = ft_itoa(ope1);
return (0); return (0);
} }
int builtin_math(const char *path, char *const av[], char *const envp[]) int builtin_math(const char *path, char *const av[], char *const envp[])
{ {
char *var; char *var;
char *value; char *value;
char *operator; char *operator;
char *operand; char *operand;
(void)path; (void)path;
(void)envp; (void)envp;
if (!av || !av[1] || !av[2] || !av[3] || av[4]) if (!av || !av[1] || !av[2] || !av[3] || av[4])
return (error_msg(MATHERR_0)); return (builtin_return_status(0, error_msg(MATHERR_0)));
init_math(&var, &value, &operator, &operand); init_math(&var, &value, &operator, &operand);
var = av[1]; var = av[1];
if (get_value(var, &value) == -1) if (get_value(var, &value))
return (-1); return (builtin_return_status(0, 1));
operator = av[2]; operator = av[2];
if (!(ft_strlen(operator) == 1 && (operator[0] == '+' || operator[0] == '-' if (ft_strlen(operator) != 1 || !(ft_strchr("+-/*%", operator[0])))
|| operator[0] == '/' || operator[0] == '*' || operator[0] == '%'))) return (builtin_return_status(0, error_msg(MATHERR_2)));
return (error_msg(MATHERR_2)); operand = av[3];
operand = av[3]; if (!ft_stris(operand, &ft_isdigit))
if (!ft_stris(operand, &ft_isdigit)) return (builtin_return_status(0, error_msg(MATHERR_3)));
return (error_msg(MATHERR_3)); if (do_math(&value, operator, operand))
if (do_math(&value, operator, operand) == -1) return (builtin_return_status(0, 1));
return (-1); builtin_setenv("setenv", (char *[]){"local", var, value, 0}, data_singleton()->local_var);
builtin_setenv("setenv", (char *[]){"local", var, value, 0}, data_singleton()->local_var); return (builtin_return_status(0, 0));
return (0);
} }

View file

@ -6,11 +6,13 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/20 15:01:45 by jhalford #+# #+# */ /* Created: 2017/01/20 15:01:45 by jhalford #+# #+# */
/* Updated: 2017/03/20 08:31:25 by jhalford ### ########.fr */ /* Updated: 2017/03/20 12:53:06 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "minishell.h" #include "minishell.h"
#define US_READ "read [-ers] [-u fd] [-t timeout] [-p prompt]"
#define US_READ_1 "[-n nchars] [-d delim] [name ...]"
t_cliopts g_read_opts[] = t_cliopts g_read_opts[] =
{ {
@ -26,8 +28,7 @@ t_cliopts g_read_opts[] =
void bt_read_usage(void) void bt_read_usage(void)
{ {
ft_dprintf(2, "{red}read: usage: read [-ers] [-u fd] [-t timeout]"); ft_dprintf(2, "usage: read %s %s\n", US_READ, US_READ_1);
ft_dprintf(2, " [-p prompt] [-n nchars] [-d delim] [name ...]{eoc}\n");
} }
int bt_read_init(t_read *data, char **av) int bt_read_init(t_read *data, char **av)
@ -117,5 +118,5 @@ int builtin_read(const char *path, char *const av[], char *const envp[])
bt_read_usage(); bt_read_usage();
if (ret != 2) if (ret != 2)
bt_read_exit(&data); bt_read_exit(&data);
return (ret); return (builtin_return_status(0, ret));
} }

View file

@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* builtin_return_status.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/20 12:48:04 by wescande #+# #+# */
/* Updated: 2017/03/20 12:49:18 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int builtin_return_status(int ret, int status)
{
set_exitstatus(status, 1);
return (ret);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 14:25:17 by jhalford #+# #+# */ /* Created: 2016/11/28 14:25:17 by jhalford #+# #+# */
/* Updated: 2017/03/20 08:24:10 by jhalford ### ########.fr */ /* Updated: 2017/03/20 14:38:25 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -39,10 +39,9 @@ int builtin_setenv(const char *path,
{ {
char ***env; char ***env;
(void)envp;
(void)path; (void)path;
if (!av || !av[0]) if (!av || !av[0])
return (1); return (builtin_return_status(0, 1));
if (ft_strcmp(av[0], "local") == 0) if (ft_strcmp(av[0], "local") == 0)
env = &data_singleton()->local_var; env = &data_singleton()->local_var;
else else
@ -53,6 +52,6 @@ int builtin_setenv(const char *path,
ft_putchar('\n'); ft_putchar('\n');
} }
else else
return (assign_var(av, env)); assign_var(av, env);
return (0); return (envp ? builtin_return_status(0, 0) : 0);
} }

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/15 11:43:34 by gwojda #+# #+# */ /* Created: 2017/02/15 11:43:34 by gwojda #+# #+# */
/* Updated: 2017/02/15 11:58:22 by gwojda ### ########.fr */ /* Updated: 2017/03/20 14:27:43 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,5 +14,13 @@
int builtin_unset(const char *path, char *const av[], char *const envp[]) int builtin_unset(const char *path, char *const av[], char *const envp[])
{ {
char *tmp;
char **av_tmp;
tmp = av[0];
av_tmp = (char **)av;
av_tmp[0] = "local";
builtin_unsetenv(path, av, envp);
av_tmp[0] = tmp;
return (builtin_unsetenv(path, av, envp)); return (builtin_unsetenv(path, av, envp));
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 14:29:17 by jhalford #+# #+# */ /* Created: 2016/11/28 14:29:17 by jhalford #+# #+# */
/* Updated: 2017/03/18 11:47:53 by gwojda ### ########.fr */ /* Updated: 2017/03/20 14:40:05 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -35,5 +35,5 @@ int builtin_unsetenv(const char *path, char *const av[], char *const envp[])
} }
i++; i++;
} }
return (0); return (builtin_return_status(0, 0));
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 14:25:17 by jhalford #+# #+# */ /* Created: 2016/11/28 14:25:17 by jhalford #+# #+# */
/* Updated: 2017/03/14 00:54:47 by ariard ### ########.fr */ /* Updated: 2017/03/20 14:38:34 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -32,7 +32,6 @@ void set_exitstatus(int status, int override)
} }
} }
astatus = ft_itoa(exitval); astatus = ft_itoa(exitval);
builtin_setenv("setenv", (char*[]){"setenv", "?", astatus, 0}, builtin_setenv("setenv", (char*[]){"setenv", "?", astatus, 0}, NULL);
data_singleton()->env);
ft_strdel(&astatus); ft_strdel(&astatus);
} }