feat: added internal variables

This commit is contained in:
2026-02-14 02:01:10 +01:00
parent 6453abfda3
commit f4cfae1107
13 changed files with 352 additions and 180 deletions

View File

@@ -6,12 +6,13 @@
/* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/02/13 21:24:45 by sede-san #+# #+# */
/* Updated: 2026/02/13 21:24:45 by sede-san ### ########.fr */
/* Updated: 2026/02/14 01:51:57 by sede-san ### ########.fr */
/* */
/* ************************************************************************** */
#include "parser.h"
#include "errors.h"
#include "variables.h"
static char *replace_value(char *original, char *value, int start, int end);
static void expand_variable(char **argument, int *i, t_minishell *minishell);
@@ -46,12 +47,13 @@ static void expand_variable(
int end;
end = start;
while (ft_isalnum((*argument)[end]) || (*argument)[end] == '_')
while (ft_isalnum((*argument)[end]) || (*argument)[end] == '_'
|| (*argument)[end] == '?')
end++;
variable_name = ft_substr(*argument, start, end - start);
if (variable_name == NULL)
return (minishell->exit = true, malloc_error());
variable_value = get_env(variable_name, minishell);
variable_value = get_var(variable_name, minishell);
free(variable_name);
if (variable_value == NULL)
variable_value = "";