From 4fe88a37306072c5eacf24ab4dd1913cc9c30d3c Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Thu, 30 Jul 2020 18:30:35 +0200 Subject: SHLVL boyy --- src/m_minishell.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/m_minishell.c b/src/m_minishell.c index 78700a1..c5901db 100644 --- a/src/m_minishell.c +++ b/src/m_minishell.c @@ -21,6 +21,7 @@ #include "s_struct.h" #include "s_init.h" #include "s_destroy.h" +#include "u_vars.h" #include "u_vars_next.h" int @@ -28,10 +29,10 @@ int char *const argv[], char *const envp[]) { - t_msh *msh; int32_t ret; + char *str; + t_msh *msh; - /* TODO: increment $SHLVL */ /* TODO: also set $SHELL | maybe not bash does not set $SHELL */ /* only zsh does */ /* TODO: handle general variables | $var */ @@ -40,6 +41,8 @@ int ft_dprintf(2, "%s\n", strerror(errno)); return (FT_RET_ALLOC); } + u_subst_var_value("$SHLVL", str = ft_itoa(ft_atoi(u_get_var_value("$SHLVL", msh)) + 1), msh); + ft_memdel((void*)&str); ret = m_argv(argc, argv, msh); s_destroy(msh); return (ret); -- cgit v1.2.3