biralavor / 42_minishell

minishell, a 42 school team project to rebuild a tiny bash, using C language. Build with @Thais-Malheiros
MIT License
3 stars 0 forks source link

remove hardcode from builtin_manager #182

Closed biralavor closed 2 months ago

biralavor commented 2 months ago

Modify hardcode of len (strncmp) to ft_strlen(cmd->lexeme):

void    builtins_manager(t_token_list *lst)
{
    static bool     arg_option;
    t_token_list    *cmd;

    cmd = lst;
    arg_option = false;
    while (cmd)
    {
        if (ft_strncmp(cmd->lexeme, "echo", 4) == 0)
            builtins_runner_echo(cmd, arg_option);
        else if (ft_strncmp(cmd->lexeme, "cd", 2) == 0)
            builtins_runner_cd(cmd);
        else if (ft_strncmp(cmd->lexeme, "pwd", 3) == 0)
            builtins_runner_pwd(cmd);
        else if (ft_strncmp(cmd->lexeme, "exit", 4) == 0)
        {
            exit_status_holder(0);
            break ;
        }
        if (NULL == cmd)
            break ;
        cmd = cmd->next;
    }
}