From 285a99b6a942c245e852506a22e1460e70e362d9 Mon Sep 17 00:00:00 2001 From: mdev9 Date: Wed, 24 Apr 2024 13:29:14 +0200 Subject: [PATCH 1/2] fixed norme on output_redirections and updated todo_list --- .gitignore | 2 +- srcs/output_redirections.c | 19 ++++++++++++------- todo_list | 18 +++--------------- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index 5e21fc9..d8b098c 100755 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ # Prerequisites *.d -todo +.tonotdo minishell diff --git a/srcs/output_redirections.c b/srcs/output_redirections.c index 41e0a17..128d708 100755 --- a/srcs/output_redirections.c +++ b/srcs/output_redirections.c @@ -6,7 +6,7 @@ /* By: tomoron +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/04/19 14:09:44 by tomoron #+# #+# */ -/* Updated: 2024/04/24 11:04:42 by marde-vr ### ########.fr */ +/* Updated: 2024/04/24 13:25:20 by marde-vr ### ########.fr */ /* */ /* ************************************************************************** */ @@ -55,6 +55,16 @@ int open_out_file(t_msh *msh, t_cmd **cur_cmd, char *filename) return (0); } +void go_to_next_out_type(t_cmd **cur_cmd) +{ + while (*cur_cmd && (*cur_cmd)->next && (!is_cmd_type(*cur_cmd) + && !is_output_type(*cur_cmd))) + *cur_cmd = (*cur_cmd)->next; + while (*cur_cmd && (*cur_cmd)->next && !is_output_type(*cur_cmd) + && !is_operand_type(*cur_cmd) && (*cur_cmd)->cmd_type != PIPE) + *cur_cmd = (*cur_cmd)->next; +} + int get_out_type(t_msh *msh, t_cmd *cmds) { t_cmd *cur_cmd; @@ -65,12 +75,7 @@ int get_out_type(t_msh *msh, t_cmd *cmds) msh->out_fd = 0; ret = 0; cur_cmd = cmds; - while (cur_cmd && cur_cmd->next && (!is_cmd_type(cur_cmd) - && !is_output_type(cur_cmd))) - cur_cmd = cur_cmd->next; - while (cur_cmd && cur_cmd->next && !is_output_type(cur_cmd) - && !is_operand_type(cur_cmd) && cur_cmd->cmd_type != PIPE) - cur_cmd = cur_cmd->next; + go_to_next_out_type(&cur_cmd); if (cur_cmd && (cur_cmd->cmd_type == CMD || cur_cmd->cmd_type == PAREN)) msh->out_type = 0; else if (cur_cmd && is_output_type(cur_cmd) && !is_operand_type(cur_cmd) diff --git a/todo_list b/todo_list index cede2c6..af6056d 100644 --- a/todo_list +++ b/todo_list @@ -1,8 +1,3 @@ -unset HOME -cd | lolcat -$SHLVL - - cat Date: Wed, 24 Apr 2024 14:06:52 +0200 Subject: [PATCH 2/2] normed --- srcs/.main.c.swp | Bin 12288 -> 0 bytes srcs/export.c | 24 +++++++++++++++--------- srcs/main.c | 6 +++--- todo_list | 1 + 4 files changed, 19 insertions(+), 12 deletions(-) delete mode 100644 srcs/.main.c.swp diff --git a/srcs/.main.c.swp b/srcs/.main.c.swp deleted file mode 100644 index a95f211163c2025b0f587682fb76b455b64c9559..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2U2GIp6vuB7)KO8;1dR{m?pE8`k9KFbMd(722*frPP@%-6Ez9ie-R_k6*v!l> zMNq1^{8e?K259*V|7ZZ#;X-tg15ix!x>I?d!CjRf8x!c`RN>O~!%rw8w zy));Yd(QvdJG+G`Yx_rc(V>2g;8;V*kKd`)b6ppe(Vi|6xVG!L4!^VHQP{Duf3ToC z({96JHtVl?i<{^CY1eeB9?Qw|3qI{n7t zF5|1Q0fOl%z31-n<&2DNVg+IaVg+IaVg+IaVg+IaVg+Ia z{wE3q^)7N8xvYrtIT@Y17M!DQe2Nu_6^Ipx6^Ipx6^Ipx6^Ipx6^Ipx6^Ipx75EP- zpjQY{@W+1NO$Z+U|1bakKYJG;2f%7@?oL7uf&0NHs|lF}z2J*G2zd^i1~#z3KCl-& z1O|Z$)`C@FB{+XOA+Law;5gU~RPZ49;Wk3v0ms2Xa3Abyp02NRMPk}M;7)S#O)`2zP_nQg14Bi88f;Ye%D1j+30v-iPunw#Mzpf(WdvF2F zffq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j~q(J Q?dQ +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/18 18:29:20 by marde-vr #+# #+# */ -/* Updated: 2024/04/24 13:06:58 by tomoron ### ########.fr */ +/* Updated: 2024/04/24 13:45:58 by marde-vr ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,18 +21,11 @@ int export_invalid_identifier(char *arg, char *name) return (1); } -t_env *export_set_env(t_env *env, char *name, char *value, int append) +t_env *set_env(t_env *env, char *name, char *value, int append) { t_env *tmp; tmp = env; - if (!value || !name) - { - free(name); - free(value); - ft_printf_fd(2, "minishell: malloc failed"); - return (env); - } while (tmp) { if (!ft_strcmp(name, tmp->name)) @@ -53,6 +46,19 @@ t_env *export_set_env(t_env *env, char *name, char *value, int append) } tmp = tmp->next; } + return (env); +} + +t_env *export_set_env(t_env *env, char *name, char *value, int append) +{ + if (!value || !name) + { + free(name); + free(value); + ft_printf_fd(2, "minishell: malloc failed"); + return (env); + } + set_env(env, name, value, append); return (env_add_back(env, name, value)); } diff --git a/srcs/main.c b/srcs/main.c index 9822822..41df755 100755 --- a/srcs/main.c +++ b/srcs/main.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/02 21:59:20 by tomoron #+# #+# */ -/* Updated: 2024/04/24 13:07:14 by tomoron ### ########.fr */ +/* Updated: 2024/04/24 13:34:44 by marde-vr ### ########.fr */ /* */ /* ************************************************************************** */ @@ -77,13 +77,13 @@ t_env *add_shlvl(t_env *env) char *tmp; tmp = ft_get_env(env, "SHLVL"); - if(!tmp) + if (!tmp) nb = 0; else nb = ft_atoi(tmp); nb++; env = export_set_env(env, ft_strdup("SHLVL"), ft_itoa(nb), 0); - return(env); + return (env); } int init_minishell(t_msh **msh, int argc, char **argv, char **envp) diff --git a/todo_list b/todo_list index af6056d..6bccdce 100644 --- a/todo_list +++ b/todo_list @@ -17,3 +17,4 @@ To test: test signals test and verify all malocs verify forbidden functions +check for any hidden or useless files