This commit is contained in:
AntoHesse 2017-03-06 23:51:26 +01:00
parent 4be3a84471
commit f70f8bd3b5
3 changed files with 16 additions and 4 deletions

@ -1 +1 @@
Subproject commit 318efc7cfb7b7cc9d3714fa19fd2be7382b6adec
Subproject commit dc155bf51cc9de83df073669a1d2a9a915f16121

View file

@ -12,13 +12,24 @@
#include "exec.h"
static int set_var(char *stream, char **var, char **value)
{
*var = ft_strdupchr(stream, '=');
stream += ft_strlenchr(stream, '=') + 1;
*value = ft_strdup(stream);
return (0);
}
int exec_var(t_btree **ast)
{
t_astnode *node;
char **av;
char *var;
char *value;
node = (*ast)->item;
av = token_to_argv(node->data.cmd.token, 0);
builtin_setenv("setenv", av, data_singleton()->local_var);
av = token_to_argv(node->data.cmd.token, 1);
set_var(av[0], &var, &value);
builtin_setenv("setenv", (char*[]){var, value, 0}, data_singleton()->local_var);
return (0);
}

View file

@ -28,6 +28,7 @@ t_execmap g_execmap[] =
{TK_FOR, &exec_for},
{TK_CASE, &exec_case},
{TK_PAREN_OPEN, &exec_case_branch},
{TK_ASSIGNEMENT_WORD, &exec_var},
/* {TK_SUBSHELL, &exec_}, */
{CMD, &exec_cmd},
{0, 0},