main loop
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
#ifndef MINISHELL_H
|
#ifndef MINISHELL_H
|
||||||
# define MINISHELL_H
|
# define MINISHELL_H
|
||||||
|
|
||||||
# define DEBUG 0
|
# define DEBUG 1
|
||||||
|
|
||||||
typedef struct s_ast_n t_ast_n;
|
typedef struct s_ast_n t_ast_n;
|
||||||
typedef struct s_node t_node;
|
typedef struct s_node t_node;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ char *ft_tabstr(char **tab)
|
|||||||
int i;
|
int i;
|
||||||
int alloc_count;
|
int alloc_count;
|
||||||
char *out;
|
char *out;
|
||||||
char *tmp;
|
// char *tmp;
|
||||||
|
|
||||||
i = -1;
|
i = -1;
|
||||||
alloc_count = 0;
|
alloc_count = 0;
|
||||||
@@ -27,10 +27,9 @@ char *ft_tabstr(char **tab)
|
|||||||
out = tab[0];
|
out = tab[0];
|
||||||
while (tab[++i])
|
while (tab[++i])
|
||||||
{
|
{
|
||||||
tmp = out;
|
// tmp = out;
|
||||||
out = ft_sprintf("%s %s", out, tab[i]);
|
out = ft_sprintf("%s %s", out, tab[i]);
|
||||||
free(tmp);
|
// free(tmp);
|
||||||
}
|
}
|
||||||
out[alloc_count] = 0;
|
|
||||||
return (out);
|
return (out);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,11 +77,18 @@ int main(int ac, char **av, char **envp)
|
|||||||
msh = init_msh(envp);
|
msh = init_msh(envp);
|
||||||
if (!msh)
|
if (!msh)
|
||||||
return (1);
|
return (1);
|
||||||
|
input = NULL;
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
while (!input || !input[0])
|
||||||
input = powerline();
|
input = powerline();
|
||||||
|
ft_debug("input: %s\n", input);
|
||||||
|
ft_debug("powerline\n");
|
||||||
msh->head = parser(input, msh);
|
msh->head = parser(input, msh);
|
||||||
|
ft_debug("parsed\n");
|
||||||
msh->ex_code = execute_command(msh->head);
|
msh->ex_code = execute_command(msh->head);
|
||||||
|
ft_debug("executed\n");
|
||||||
free(input);
|
free(input);
|
||||||
|
input = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user