From 487a66394061f2d14a2fa421302966b5442d643f Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Mon, 27 Jul 2020 18:55:07 +0200 Subject: I couldn't see shit --- src/m_minishell.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/m_minishell.c (limited to 'src/m_minishell.c') diff --git a/src/m_minishell.c b/src/m_minishell.c new file mode 100644 index 0000000..1e065b4 --- /dev/null +++ b/src/m_minishell.c @@ -0,0 +1,60 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* m_minishell.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include +#include +#include +#include + +#include "f_fail.h" +#include "m_argv.h" +#include "s_struct.h" +#include "s_init.h" +#include "s_destroy.h" + +int + main(int argc, + char *const argv[], + char *const envp[]) +{ + t_msh *msh; + int32_t ret; + + /* TODO: increment $SHLVL */ + /* TODO: also set $SHELL | maybe not bash does not set $SHELL */ + /* only zsh does */ + /* TODO: handle general variables | $var */ + if (!(msh = init_msh(argv, envp))) + { + ft_dprintf(2, "%s\n", strerror(errno)); + return (FT_RET_ALLOC); + } + ret = m_argv(argc, argv, msh); + s_destroy(msh); + return (ret); +} + +/* +** ====== INFO ====== +** Files prefixes info +** ------------------- +** b_ -> builtins related +** d_ -> defines related +** e_ -> exec related +** f_ -> failure related +** m_ -> core minishell related +** p_ -> parse related +** s_ -> structs related +** u_ -> utils related +** v_ -> general purpose variables related +*/ -- cgit v1.2.3 From 280ecd341f1ec88abe325fa69b197bca3e43d2f1 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Mon, 27 Jul 2020 22:38:54 +0200 Subject: Now can subst env vars --- src/m_minishell.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/m_minishell.c') diff --git a/src/m_minishell.c b/src/m_minishell.c index 1e065b4..66426b7 100644 --- a/src/m_minishell.c +++ b/src/m_minishell.c @@ -21,6 +21,7 @@ #include "s_struct.h" #include "s_init.h" #include "s_destroy.h" +#include "u_vars_next.h" int main(int argc, @@ -39,6 +40,7 @@ int ft_dprintf(2, "%s\n", strerror(errno)); return (FT_RET_ALLOC); } + /* TODO: DELET THIS */ ret = m_argv(argc, argv, msh); s_destroy(msh); return (ret); -- cgit v1.2.3 From 6dc6bf6f46b736299826bfdd63192bdee16ba875 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Thu, 30 Jul 2020 18:08:50 +0200 Subject: Less retarded stuff --- src/m_minishell.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/m_minishell.c') diff --git a/src/m_minishell.c b/src/m_minishell.c index 66426b7..78700a1 100644 --- a/src/m_minishell.c +++ b/src/m_minishell.c @@ -40,7 +40,6 @@ int ft_dprintf(2, "%s\n", strerror(errno)); return (FT_RET_ALLOC); } - /* TODO: DELET THIS */ ret = m_argv(argc, argv, msh); s_destroy(msh); return (ret); -- cgit v1.2.3 From 4fe88a37306072c5eacf24ab4dd1913cc9c30d3c Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Thu, 30 Jul 2020 18:30:35 +0200 Subject: SHLVL boyy --- src/m_minishell.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/m_minishell.c') diff --git a/src/m_minishell.c b/src/m_minishell.c index 78700a1..c5901db 100644 --- a/src/m_minishell.c +++ b/src/m_minishell.c @@ -21,6 +21,7 @@ #include "s_struct.h" #include "s_init.h" #include "s_destroy.h" +#include "u_vars.h" #include "u_vars_next.h" int @@ -28,10 +29,10 @@ int char *const argv[], char *const envp[]) { - t_msh *msh; int32_t ret; + char *str; + t_msh *msh; - /* TODO: increment $SHLVL */ /* TODO: also set $SHELL | maybe not bash does not set $SHELL */ /* only zsh does */ /* TODO: handle general variables | $var */ @@ -40,6 +41,8 @@ int ft_dprintf(2, "%s\n", strerror(errno)); return (FT_RET_ALLOC); } + u_subst_var_value("$SHLVL", str = ft_itoa(ft_atoi(u_get_var_value("$SHLVL", msh)) + 1), msh); + ft_memdel((void*)&str); ret = m_argv(argc, argv, msh); s_destroy(msh); return (ret); -- cgit v1.2.3 From 40b5a588c89890ea83d0e4fcaa9f3fdf539cb064 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Thu, 30 Jul 2020 18:36:31 +0200 Subject: Norm update --- src/m_minishell.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/m_minishell.c') diff --git a/src/m_minishell.c b/src/m_minishell.c index c5901db..8a76598 100644 --- a/src/m_minishell.c +++ b/src/m_minishell.c @@ -41,7 +41,8 @@ int ft_dprintf(2, "%s\n", strerror(errno)); return (FT_RET_ALLOC); } - u_subst_var_value("$SHLVL", str = ft_itoa(ft_atoi(u_get_var_value("$SHLVL", msh)) + 1), msh); + u_subst_var_value("$SHLVL", + str = ft_itoa(ft_atoi(u_get_var_value("$SHLVL", msh)) + 1), msh); ft_memdel((void*)&str); ret = m_argv(argc, argv, msh); s_destroy(msh); -- cgit v1.2.3 From 8797f947d58371ccbef5c34f4ebf64c103a38942 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Thu, 30 Jul 2020 18:54:50 +0200 Subject: Removed todo --- src/m_minishell.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/m_minishell.c') diff --git a/src/m_minishell.c b/src/m_minishell.c index 8a76598..6e656a6 100644 --- a/src/m_minishell.c +++ b/src/m_minishell.c @@ -33,8 +33,6 @@ int char *str; t_msh *msh; - /* TODO: also set $SHELL | maybe not bash does not set $SHELL */ - /* only zsh does */ /* TODO: handle general variables | $var */ if (!(msh = init_msh(argv, envp))) { -- cgit v1.2.3 From ced3be528b52b59ad613f282e37d653c16ef85d9 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Thu, 30 Jul 2020 19:17:05 +0200 Subject: I'm retarded --- src/m_minishell.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/m_minishell.c') diff --git a/src/m_minishell.c b/src/m_minishell.c index 6e656a6..e14dbdc 100644 --- a/src/m_minishell.c +++ b/src/m_minishell.c @@ -23,6 +23,7 @@ #include "s_destroy.h" #include "u_vars.h" #include "u_vars_next.h" +#include "s_lvars.h" int main(int argc, @@ -42,6 +43,7 @@ int u_subst_var_value("$SHLVL", str = ft_itoa(ft_atoi(u_get_var_value("$SHLVL", msh)) + 1), msh); ft_memdel((void*)&str); + lvars_add_front(&msh->vars, lvars_new("var", "value")); ret = m_argv(argc, argv, msh); s_destroy(msh); return (ret); -- cgit v1.2.3 From af663bf8cbc9e97d9818959de69a1d8a6c423cbe Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Thu, 30 Jul 2020 19:45:42 +0200 Subject: Work in progress, freed leak --- src/m_minishell.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/m_minishell.c') diff --git a/src/m_minishell.c b/src/m_minishell.c index e14dbdc..9306955 100644 --- a/src/m_minishell.c +++ b/src/m_minishell.c @@ -31,7 +31,8 @@ int char *const envp[]) { int32_t ret; - char *str; + char *str_one; + char *str_two; t_msh *msh; /* TODO: handle general variables | $var */ @@ -41,9 +42,12 @@ int return (FT_RET_ALLOC); } u_subst_var_value("$SHLVL", - str = ft_itoa(ft_atoi(u_get_var_value("$SHLVL", msh)) + 1), msh); - ft_memdel((void*)&str); - lvars_add_front(&msh->vars, lvars_new("var", "value")); + str_one =ft_itoa( + ft_atoi(str_two = u_get_var_value("$SHLVL", msh)) + 1), msh); + ft_memdel((void*)&str_one); + ft_memdel((void*)&str_two); + /* TODO: delet this */ + u_subst_var_value("$var", "value", msh); ret = m_argv(argc, argv, msh); s_destroy(msh); return (ret); -- cgit v1.2.3 From 1c1901379b76e9869e3612d217c60784858c60ad Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Fri, 31 Jul 2020 23:59:35 +0200 Subject: Leak free --- src/m_minishell.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/m_minishell.c') diff --git a/src/m_minishell.c b/src/m_minishell.c index 9306955..b4a8876 100644 --- a/src/m_minishell.c +++ b/src/m_minishell.c @@ -47,7 +47,6 @@ int ft_memdel((void*)&str_one); ft_memdel((void*)&str_two); /* TODO: delet this */ - u_subst_var_value("$var", "value", msh); ret = m_argv(argc, argv, msh); s_destroy(msh); return (ret); -- cgit v1.2.3 From bfaf4c53a8406ea0bfbd8699807b567a5322a03f Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Mon, 3 Aug 2020 19:00:47 +0200 Subject: Export is working --- src/m_minishell.c | 9 --------- 1 file changed, 9 deletions(-) (limited to 'src/m_minishell.c') diff --git a/src/m_minishell.c b/src/m_minishell.c index b4a8876..dd47ac3 100644 --- a/src/m_minishell.c +++ b/src/m_minishell.c @@ -21,8 +21,6 @@ #include "s_struct.h" #include "s_init.h" #include "s_destroy.h" -#include "u_vars.h" -#include "u_vars_next.h" #include "s_lvars.h" int @@ -31,8 +29,6 @@ int char *const envp[]) { int32_t ret; - char *str_one; - char *str_two; t_msh *msh; /* TODO: handle general variables | $var */ @@ -41,11 +37,6 @@ int ft_dprintf(2, "%s\n", strerror(errno)); return (FT_RET_ALLOC); } - u_subst_var_value("$SHLVL", - str_one =ft_itoa( - ft_atoi(str_two = u_get_var_value("$SHLVL", msh)) + 1), msh); - ft_memdel((void*)&str_one); - ft_memdel((void*)&str_two); /* TODO: delet this */ ret = m_argv(argc, argv, msh); s_destroy(msh); -- cgit v1.2.3