Merge branch 'feature/core' into develop
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/10/22 19:10:13 by sede-san #+# #+# */
|
||||
/* Updated: 2025/10/22 19:27:19 by sede-san ### ########.fr */
|
||||
/* Updated: 2025/10/23 23:19:58 by sede-san ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -20,21 +20,35 @@
|
||||
/******************************************************************************/
|
||||
|
||||
typedef struct s_minishell t_minishell;
|
||||
typedef struct s_variables t_variables;
|
||||
|
||||
/**
|
||||
* @brief Structure that holds both environment and internal variables
|
||||
*
|
||||
* This structure contains pointers to arrays of strings that represent
|
||||
* different types of variables used in the minishell program.
|
||||
*
|
||||
* @param environment Array of environment variable strings (NULL-terminated)
|
||||
//// @param intp Array of internal variable strings (NULL-terminated)
|
||||
*/
|
||||
typedef struct s_variables
|
||||
{
|
||||
char **environment;
|
||||
// char **internal;
|
||||
} t_variables;
|
||||
|
||||
/**
|
||||
* @brief Main minishell structure containing global state information
|
||||
*
|
||||
* This structure holds the essential data for the minishell program,
|
||||
* including the environment variables and the exit status of the last
|
||||
* executed command.
|
||||
* This structure holds the essential data for the minishell program.
|
||||
*
|
||||
* @param env Array of environment variable strings in "KEY=VALUE" format
|
||||
* @param variables Structure that holds both environment and internal variables
|
||||
* @param exit_status Exit status code of the last executed command (0-255)
|
||||
*/
|
||||
typedef struct s_minishell
|
||||
{
|
||||
char **env;
|
||||
u_int8_t exit_status;
|
||||
t_variables variables;
|
||||
u_int8_t exit_status;
|
||||
} t_minishell;
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/10/20 20:51:33 by sede-san #+# #+# */
|
||||
/* Updated: 2025/10/22 17:02:52 by sede-san ### ########.fr */
|
||||
/* Updated: 2025/10/23 14:14:30 by sede-san ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -17,7 +17,7 @@ int minishell_init(
|
||||
char **envp
|
||||
){
|
||||
ft_bzero(minishell, sizeof(t_minishell));
|
||||
minishell->env = envp;
|
||||
minishell->variables.environment = envp;
|
||||
return (1);
|
||||
}
|
||||
|
||||
@@ -29,9 +29,16 @@ u_int8_t minishell_run(
|
||||
while (1)
|
||||
{
|
||||
line = readline("minishell > ");
|
||||
if (!*line)
|
||||
{
|
||||
free(line);
|
||||
continue ;
|
||||
}
|
||||
add_history(line);
|
||||
parse(line, minishell);
|
||||
if (!ft_strcmp(line, "exit"))
|
||||
break ;
|
||||
printf("%s\n", line);
|
||||
// printf("%s\n", line);
|
||||
free(line);
|
||||
}
|
||||
free(line);
|
||||
@@ -41,5 +48,6 @@ u_int8_t minishell_run(
|
||||
void minishell_clear(
|
||||
t_minishell *minishell
|
||||
){
|
||||
rl_clear_history();
|
||||
ft_bzero(minishell, sizeof(t_minishell));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user