-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathexpand_variables.c
38 lines (35 loc) · 1.27 KB
/
expand_variables.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* expand_variables.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bmachado <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/19 17:54:50 by bmachado #+# #+# */
/* Updated: 2022/02/23 10:48:52 by bmachado ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void expand_vars(t_token **token_lst, t_shell *table)
{
t_token *token;
char *tmp;
token = *token_lst;
while (token)
{
if (token->type == DOLLAR)
{
if (ft_strcmp(token->value, "$?") == 0)
{
tmp = ft_itoa(g_shell.error);
token->value = tmp;
}
else
{
tmp = expanded_var(token->value, table);
token->value = tmp;
}
}
token = token->next;
}
}