fix: error in parsing is now right supported

This commit is contained in:
starnakin 2023-07-01 21:59:35 +02:00
parent 770facd9d7
commit a3bd87f956
3 changed files with 19 additions and 21 deletions

View File

@ -29,20 +29,18 @@ int main(int ac, char **av, char **env_str)
{
cmds_list = parsing(line, env);
free(line);
if (cmds_list == NULL)
if (cmds_list != NULL)
{
lst_clear(env, &env_del);
return 1;
}
for (size_t i = 0; cmds_list[i] != NULL; i++)
{
if (cmds_list_exec(cmds_list[i], env))
for (size_t i = 0; cmds_list[i] != NULL; i++)
{
lst_clear(env, &env_del);
return 1;
if (cmds_list_exec(cmds_list[i], env))
{
lst_clear(env, &env_del);
return 1;
}
}
cmds_list_destroyer(cmds_list);
}
cmds_list_destroyer(cmds_list);
line = get_user_input(env);
}
lst_clear(env, &env_del);

View File

@ -1,9 +1,4 @@
#include "../cmd/cmd.h"
#include "../utils/utils.h"
#include "../exec/exec.h"
#include "../../lib/bozolib/bozolib.h"
#include <stddef.h>
#include "parsing.h"
char* parsing_executable(const char* executable, lst** env)
{
if (strchr("./", executable[0]))
@ -13,9 +8,8 @@ char* parsing_executable(const char* executable, lst** env)
int parsing_cmd(char *str, cmd* command, lst** env)
{
// if (get_redirections(str, command))
// return 1;
// remove_redirections(str);
if (get_redirections(str, command))
return 1;
command->args = split_quoted_charset(str, "\t ");
if (command->args == NULL)
return 1;
@ -43,7 +37,11 @@ lst **parsing_pipe(const char *str, lst** env)
current = *cmds;
for (size_t i = 0; cmds_str[i] != NULL; i++)
{
parsing_cmd(cmds_str[i], current->content, env);
if (parsing_cmd(cmds_str[i], current->content, env))
{
tab_free((void**)cmds_str);
return NULL;
}
current = current->next;
}
tab_free((void**)cmds_str);

View File

@ -1,4 +1,6 @@
#pragma once
#include "../../lib/bozolib/bozolib.h"
#include "../exec/exec.h"
#include "../../lib/bozolib/bozolib.h"
#include "../redirection/redirection.h"
lst*** parsing(const char* str, lst** env);