1
0
mirror of https://github.com/KeyZox71/ft_minipowershell.git synced 2025-05-13 16:08:45 +02:00

🔨」 fix: if folder crash

This commit is contained in:
2024-07-14 15:39:28 +02:00
parent 4739d6b6f9
commit fe0285a5b2
17 changed files with 119 additions and 18 deletions

View File

@ -6,7 +6,7 @@
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/24 11:18:04 by adjoly #+# #+# */
/* Updated: 2024/07/13 18:51:03 by adjoly ### ########.fr */
/* Updated: 2024/07/14 15:37:11 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -20,6 +20,7 @@ void sig_c(int code)
rl_on_new_line();
rl_replace_line("", 0);
rl_redisplay();
get_exit_code(0);
}
bool run_checks(char *rl)
@ -50,30 +51,34 @@ int main(int ac, char **av, char **env)
get_env(&env_l);
if (!env_l)
return (EXIT_FAILURE);
get_exit_code(12);
get_exit_code(727);
while (1)
{
signal(SIGINT, &sig_c);
signal(SIGQUIT, SIG_IGN);
prompt = get_prompt(env_l);
rl = readline(prompt);
free(prompt);
if (!rl)
{
get_exit_code(0);
break ;
}
if (run_checks(rl))
{
free(rl);
continue ;
}
add_history(rl);
rl = env_var_replace(rl, env_l);
piped = tokenizer(rl);
get_list(&piped);
if (check_argv(piped))
{
free(rl);
ft_lstclear(&piped, &free_token);
continue ;
}
add_history(rl);
cmd_list = get_cmd_list(piped);
free(rl);
ft_lstclear(&piped, &free_token);
@ -96,5 +101,5 @@ int main(int ac, char **av, char **env)
free(rl);
rl_clear_history();
ft_envclear(&env_l, free);
return (727);
return (get_exit_code(-1));
}