summaryrefslogtreecommitdiffstats
path: root/src/s_init.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-08-03 19:00:47 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-08-03 19:00:47 +0200
commitbfaf4c53a8406ea0bfbd8699807b567a5322a03f (patch)
treeb8ce7d07b3094de0c4ba98160f35cf7e64eeae1d /src/s_init.c
parentAdded $ for varname (diff)
download42-minishell-bfaf4c53a8406ea0bfbd8699807b567a5322a03f.tar.gz
42-minishell-bfaf4c53a8406ea0bfbd8699807b567a5322a03f.tar.bz2
42-minishell-bfaf4c53a8406ea0bfbd8699807b567a5322a03f.tar.xz
42-minishell-bfaf4c53a8406ea0bfbd8699807b567a5322a03f.tar.zst
42-minishell-bfaf4c53a8406ea0bfbd8699807b567a5322a03f.zip
Export is working
Diffstat (limited to '')
-rw-r--r--src/s_init.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/s_init.c b/src/s_init.c
index 454cb67..377cd91 100644
--- a/src/s_init.c
+++ b/src/s_init.c
@@ -18,6 +18,8 @@
#include "d_define.h"
#include "m_funptr.h"
#include "s_init.h"
+#include "u_vars.h"
+#include "u_vars_next.h"
static char
**dupenv_del(char **nenvp,
@@ -58,6 +60,19 @@ static char
return (nenvp);
}
+static void
+ inc_shlvl(t_msh *msh)
+{
+ char *str_one;
+ char *str_two;
+
+ u_subst_var_value("$SHLVL",
+ str_one = ft_itoa(
+ ft_atoi(str_two = u_get_var_value("$SHLVL", msh)) + 1), msh);
+ ft_memdel((void*)&str_one);
+ ft_memdel((void*)&str_two);
+}
+
t_msh
*init_msh(char *const argv[],
char *const envp[])
@@ -81,5 +96,6 @@ t_msh
init_buptr(msh);
msh->curr = NULL;
msh->vars = NULL;
+ inc_shlvl(msh);
return (msh);
}