summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-08-03 17:30:33 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-08-03 17:30:33 +0200
commitc3d540a4d1627ba8e4c140ba9aa76b85333d7a07 (patch)
treecab22fa68abbf87464d2133c9f9c0688a32ce067
parentSplitted var (diff)
download42-minishell-c3d540a4d1627ba8e4c140ba9aa76b85333d7a07.tar.gz
42-minishell-c3d540a4d1627ba8e4c140ba9aa76b85333d7a07.tar.bz2
42-minishell-c3d540a4d1627ba8e4c140ba9aa76b85333d7a07.tar.xz
42-minishell-c3d540a4d1627ba8e4c140ba9aa76b85333d7a07.tar.zst
42-minishell-c3d540a4d1627ba8e4c140ba9aa76b85333d7a07.zip
Added $ for varname
Diffstat (limited to '')
-rw-r--r--src/b_export_next.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/b_export_next.c b/src/b_export_next.c
index f0bb804..683fdd0 100644
--- a/src/b_export_next.c
+++ b/src/b_export_next.c
@@ -30,9 +30,10 @@ static char
while (arg[len] != '=' && arg[len] != '\0')
len++;
len += 1;
- if ((var[FT_VAR_NAME] = (char*)malloc((len) * sizeof(char))) == NULL)
+ if ((var[FT_VAR_NAME] = (char*)malloc((len + 1) * sizeof(char))) == NULL)
f_fail_alloc_and_destroy(msh);
- ft_strlcpy(var[FT_VAR_NAME], arg, len);
+ var[FT_VAR_NAME][0] = '$';
+ ft_strlcpy(var[FT_VAR_NAME] + 1, arg, len);
if ((var[FT_VAR_VAL] = ft_strdup(arg + len)) == NULL)
f_fail_alloc_and_destroy(msh);
var[FT_VAR_NULL] = NULL;
@@ -46,5 +47,6 @@ void
char **var;
var = b_get_var(arg, msh);
+ ft_printf("[%s] - [%s]\n", var[FT_VAR_NAME], var[FT_VAR_VAL]);
ft_delwords(var);
}