Merge remote-tracking branch 'origin/quinten' into willem
This commit is contained in:
commit
ec2b939f41
@ -42,7 +42,13 @@ char *expander_parse_string(char *s, t_minishell *msh)
|
||||
j = 0;
|
||||
while (s[i])
|
||||
{
|
||||
if (s[i] == '$' && s[i + 1] && current)
|
||||
if (s[i] == '~' && current)
|
||||
{
|
||||
i++;
|
||||
expander_expand_dollar(s + i, string, &j, current);
|
||||
current = current->next;
|
||||
}
|
||||
else if (s[i] == '$' && s[i + 1] && current)
|
||||
{
|
||||
i++;
|
||||
i += expander_expand_dollar(s + i, string, &j, current);
|
||||
|
||||
@ -10,6 +10,8 @@
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "environment.h"
|
||||
#include "libft.h"
|
||||
#include "minishell.h"
|
||||
|
||||
static char *ft_itoa_safe(t_minishell *msh, int n)
|
||||
@ -54,6 +56,8 @@ t_list *expander_parse_variables(const char *s, t_minishell *msh)
|
||||
ft_lstadd_back(&var_list, ft_lstnew_safe(msh, NULL));
|
||||
}
|
||||
}
|
||||
else if (s[i] == '~')
|
||||
ft_lstadd_back(&var_list, ft_lstnew_safe(msh, environment_get(msh, "HOME")));
|
||||
i++;
|
||||
}
|
||||
return (var_list);
|
||||
|
||||
@ -27,7 +27,9 @@ static int parser_should_expand(t_list *value)
|
||||
while (token->value[i])
|
||||
{
|
||||
t_val = token->value;
|
||||
if (t_val[i] == '$' && expander_character_valid(t_val[i + 1]))
|
||||
if (t_val[i] == '~' && (t_val[i + 1] == '/' || t_val[i + 1] == ' ' || t_val[i + 1] == 0) && token->type == T_WORD)
|
||||
return (1);
|
||||
else if (t_val[i] == '$' && expander_character_valid(t_val[i + 1]))
|
||||
return (1);
|
||||
else if (t_val[i] == '$' && t_val[i + 1] == '?')
|
||||
return (1);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user