diff --git a/42sh/src/main/data_init.c b/42sh/src/main/data_init.c index 12161d0d..cae2ce88 100644 --- a/42sh/src/main/data_init.c +++ b/42sh/src/main/data_init.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */ -/* Updated: 2017/03/16 23:25:46 by ariard ### ########.fr */ +/* Updated: 2017/03/17 17:41:33 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -27,9 +27,13 @@ int data_init(int ac, char **av) data->local_var = NULL; builtin_setenv(NULL, (char *[]){"local", "IFS", "\n ", 0}, NULL); set_exitstatus(0, 1); - shlvl = ft_itoa(ft_atoi(ft_getenv(data->env, "SHLVL")) + 1); - builtin_setenv(NULL, (char *[]){"setenv", "SHLVL", shlvl, 0}, NULL); - ft_strdel(&shlvl); + shlvl = ft_getenv(data->env, "SHLVL"); + if (shlvl) + { + shlvl = ft_itoa(ft_atoi(shlvl) + 1); + builtin_setenv(NULL, (char *[]){"setenv", "SHLVL", shlvl, 0}, NULL); + ft_strdel(&shlvl); + } data->comp = NULL; data->opts = 0; exec_reset();