summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/m_minishell.c2
-rw-r--r--src/u_vars.c22
2 files changed, 20 insertions, 4 deletions
diff --git a/src/m_minishell.c b/src/m_minishell.c
index 6e656a6..e14dbdc 100644
--- a/src/m_minishell.c
+++ b/src/m_minishell.c
@@ -23,6 +23,7 @@
#include "s_destroy.h"
#include "u_vars.h"
#include "u_vars_next.h"
+#include "s_lvars.h"
int
main(int argc,
@@ -42,6 +43,7 @@ int
u_subst_var_value("$SHLVL",
str = ft_itoa(ft_atoi(u_get_var_value("$SHLVL", msh)) + 1), msh);
ft_memdel((void*)&str);
+ lvars_add_front(&msh->vars, lvars_new("var", "value"));
ret = m_argv(argc, argv, msh);
s_destroy(msh);
return (ret);
diff --git a/src/u_vars.c b/src/u_vars.c
index fafc2fa..9978df5 100644
--- a/src/u_vars.c
+++ b/src/u_vars.c
@@ -20,7 +20,6 @@
#include "s_lcom.h"
#include "s_struct.h"
-
static char
*set_rva(const char varname[],
t_msh *msh)
@@ -117,9 +116,24 @@ static char
*get_cstm_vr(const char varname[],
t_msh *msh)
{
- (void)varname;
- (void)msh;
- return (NULL);
+ t_lvars *ptr;
+ char *varval;
+
+ ptr = msh->vars;
+ while (ptr != NULL &&
+ ft_strncmp(varname + 1, ptr->name, ft_strlen(varname + 1)) != 0)
+ {
+ ptr = ptr->next;
+ }
+ if (ptr != NULL)
+ {
+ varval = ft_strdup(ptr->val);
+ return (varval);
+ }
+ else
+ {
+ return (NULL);
+ }
}
/*