From c3d540a4d1627ba8e4c140ba9aa76b85333d7a07 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Mon, 3 Aug 2020 17:30:33 +0200 Subject: Added $ for varname --- src/b_export_next.c | 6 ++++-- 1 file 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); } -- cgit v1.2.3