wip builtins: env, exit

This commit is contained in:
LuckyLaszlo
2021-10-10 08:57:33 +02:00
parent a7e0066458
commit c0068a5ec7
9 changed files with 113 additions and 21 deletions

View File

@@ -6,7 +6,7 @@
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/04 05:59:26 by lperrey #+# #+# */
/* Updated: 2021/10/08 19:11:03 by lperrey ### ########.fr */
/* Updated: 2021/10/10 08:50:20 by lperrey ### ########.fr */
/* */
/* ************************************************************************** */
@@ -24,13 +24,13 @@ void shell_loop(t_all *c)
line_input = readline(c->prompt);
if (line_input && *line_input)
{
if (!ft_strncmp(line_input, "exit", 5))
exit(EXIT_SUCCESS);
if (!ft_strncmp(line_input, "env", 4)) // temp placeholder
builtin_env(0, NULL, c);
else if (!ft_strncmp(line_input, "exit", 5)) // temp placeholder
builtin_exit(0, NULL, c);
else
printf("echo: %s\n", line_input);
}
//rl_redisplay();
//rl_on_new_line();
}
}
@@ -63,13 +63,9 @@ int main(int argc, char *argv[], char *envp[])
{
t_all c;
ft_putendl_arr_fd(envp, 1);
//char *path = getenv("PATH");
(void)argc;
(void)argv;
(void)envp;
if (!init(&c))
if (!init(&c, envp))
exit(EXIT_FAILURE);
shell_loop(&c);
return (0);