diff options
Diffstat (limited to '')
-rw-r--r-- | src/b_export.c | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/src/b_export.c b/src/b_export.c index 411f142..8b72b64 100644 --- a/src/b_export.c +++ b/src/b_export.c @@ -80,12 +80,30 @@ void b_add_to_env_from_globals(const char varname[], msh->envp = nenvp; } -uint8_t b_export(char *args[], t_msh *msh) +static void b_classic_export(char *ptr[], t_msh *msh) { - /* TODO: norme */ - char **ptr; char varval[4096]; char fmt[4096]; + + if (check_equals(*ptr) == FALSE) + { + ft_sprintf(fmt, "$%s", *ptr); + u_get_custom_var(varval, fmt, 4096, msh); + if (varval[0] != C_NUL) + { + ft_sprintf(fmt, "%s=%s", *ptr, varval); + b_add_to_env_from_globals(*ptr, fmt, msh); + } + } + else + { + b_export_with_equals(*ptr, msh); + } +} + +uint8_t b_export(char *args[], t_msh *msh) +{ + char **ptr; uint8_t r; if (args[0] == NULL) @@ -101,18 +119,7 @@ uint8_t b_export(char *args[], t_msh *msh) ptr++; continue ; } - if (check_equals(*ptr) == FALSE) - { - ft_sprintf(fmt, "$%s", *ptr); - u_get_custom_var(varval, fmt, 4096, msh); - if (varval[0] != C_NUL) - { - ft_sprintf(fmt, "%s=%s", *ptr, varval); - b_add_to_env_from_globals(*ptr, fmt, msh); - } - } - else if (check_equals(*ptr) == TRUE) - b_export_with_equals(*ptr, msh); + b_classic_export(ptr, msh); ptr++; } return (r); |