exec var
This commit is contained in:
parent
4be3a84471
commit
f70f8bd3b5
3 changed files with 16 additions and 4 deletions
|
|
@ -1 +1 @@
|
||||||
Subproject commit 318efc7cfb7b7cc9d3714fa19fd2be7382b6adec
|
Subproject commit dc155bf51cc9de83df073669a1d2a9a915f16121
|
||||||
|
|
@ -12,13 +12,24 @@
|
||||||
|
|
||||||
#include "exec.h"
|
#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)
|
int exec_var(t_btree **ast)
|
||||||
{
|
{
|
||||||
t_astnode *node;
|
t_astnode *node;
|
||||||
char **av;
|
char **av;
|
||||||
|
char *var;
|
||||||
|
char *value;
|
||||||
|
|
||||||
node = (*ast)->item;
|
node = (*ast)->item;
|
||||||
av = token_to_argv(node->data.cmd.token, 0);
|
av = token_to_argv(node->data.cmd.token, 1);
|
||||||
builtin_setenv("setenv", av, data_singleton()->local_var);
|
set_var(av[0], &var, &value);
|
||||||
|
builtin_setenv("setenv", (char*[]){var, value, 0}, data_singleton()->local_var);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ t_execmap g_execmap[] =
|
||||||
{TK_FOR, &exec_for},
|
{TK_FOR, &exec_for},
|
||||||
{TK_CASE, &exec_case},
|
{TK_CASE, &exec_case},
|
||||||
{TK_PAREN_OPEN, &exec_case_branch},
|
{TK_PAREN_OPEN, &exec_case_branch},
|
||||||
|
{TK_ASSIGNEMENT_WORD, &exec_var},
|
||||||
/* {TK_SUBSHELL, &exec_}, */
|
/* {TK_SUBSHELL, &exec_}, */
|
||||||
{CMD, &exec_cmd},
|
{CMD, &exec_cmd},
|
||||||
{0, 0},
|
{0, 0},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue