From 255892e12e7b5ab5063385da0a03099713cdd511 Mon Sep 17 00:00:00 2001 From: Camille Chauvet Date: Tue, 21 Feb 2023 15:07:14 +0100 Subject: [PATCH 1/3] fix: use builtin --- .execution.c.swp | Bin 0 -> 20480 bytes execution.c | 34 +++++++++++++++++++--------------- main.c | 9 +++++++-- minishell.h | 4 ++-- vsupp | 15 +++++++++++++++ 5 files changed, 43 insertions(+), 19 deletions(-) create mode 100644 .execution.c.swp create mode 100644 vsupp diff --git a/.execution.c.swp b/.execution.c.swp new file mode 100644 index 0000000000000000000000000000000000000000..99fb472180b65abdc713e53a5aad1b4f6631ef53 GIT binary patch literal 20480 zcmeI2TZ|i58ONthn`TM_y+{-_5<1xxS+Cc-UOQ>jI+rG(qM{^iQ%I>Ot>d-FyF=`; zWsf(zO}IQXA`K9fA|%=eUIBqpp`!8tRRvKipb`j(0QG^2NPq;DP^%z>KrO#>nenW5 zcGo2lE$VUfi#_M^o$vh5Wp>VdGt>8f6|f3e1*`&A0jt3O zlLBFTo%2~7zS1~-*nD3x@O_oJ&YAC-f&6vm`eyU}*g(Fyv|m;MtAJI&Dqt0`3RnfK z0#*U5fK|XMU=^?myaftWYL4?`9_}ArPvgA*KWuz>>OG{vM)={o9p?z#0zcj8I14Za zzq!tFPQat!!+mfNHo$uL=er!|6?hrW!>{3aI0+}yX$GHICfUm+C zI1MM^1l$8VAq$&f16&0!x{mV2kb7w&{TAYc<*3$Jg$H~0%&fZxN<;05>sd>-mh zg^$8PxEBPxA8vv-u5p~#;8l1Yz7OAoufZue1`F^o?1P;!1@DD7(E2?55?+LF!5R26 zoCY}-w?H0lgg;*GIM2eDUV(JKzSm5-xHW^BTMg&%v|s9e5H>Ko>ly z!F_N$Y=`&3zc>i`2fPd~!CCk^JORhyPS^{3Kz&^I(~j%9nM_!&Hftg~E~>pw#|y&A z-GR5j|J7CyaydS^yIw2%f!HPLweEw{5ABfEOs2|f^+JWZwg?iwis z+H~BkzAVpI8a<>Fxd?|)n+?`<;mUJa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5)wbANwe6QbgMK1?cmOLgKNS9}o1+irdr^V_`V^m(I7v(D|ceyz~NVUe-bM%Drm4Pg>ijNtpnpb|JV=$EL@xGABy6PQ>SohU6|f3e1>RZ((xU&~PHAb8h{O7~Lfv7irvmB`xG~=$Vibb{U<8qOH ii9eLb74qyuhY_Vm=C+R}qD}{9XCVqhPNd7YpZ@?;BEDS! literal 0 HcmV?d00001 diff --git a/execution.c b/execution.c index fa73ae0..6bf9281 100644 --- a/execution.c +++ b/execution.c @@ -6,7 +6,7 @@ /* By: cchauvet executable, "pwd") == 0) */ - /* return (pwd(env, cmd->fd_out)); */ - if (ft_strcmp(cmd->executable, "env") == 0) - return (print_env(env, cmd->fd_out)); - if (ft_strcmp(cmd->executable, "export") == 0) - return (print_export(env, cmd->fd_out)); - /* if (ft_strcmp(cmd->executable, "cd") == 0) */ - /* return (move_folder(cmd->args[0], cmd->fd_out)); */ + int return_code; + + return_code = -1; + if (ft_strcmp(cmd->executable, "pwd") == 0) + return_code = pwd(cmd->fd_out); + else if (ft_strcmp(cmd->executable, "env") == 0) + return_code = print_env(env, cmd->fd_out); + else if (ft_strcmp(cmd->executable, "export") == 0) + return_code = (print_export(env, cmd->fd_out)); + else if (ft_strcmp(cmd->executable, "cd") == 0) + return_code = (move_folder(cmd->args[0], cmd->fd_out)); /* if (ft_strcmp(cmd->executable, "unset") == 0) */ - /* return (unset(env, cmd->args, cmd->fd_out)); */ - /* if (ft_strcmp(cmd->executable, "echo") == 0) */ - /* return (echo(cmd->fd_out, cmd->args[0])); */ - if (ft_strcmp(cmd->executable, "exit") == 0) - return (-2); - return (-1); + /* return_code = (unset(env, cmd->args, cmd->fd_out)); */ + else if (ft_strcmp(cmd->executable, "echo") == 0) + return_code = (echo(cmd->fd_out, cmd->args + 1)); + else if (ft_strcmp(cmd->executable, "exit") == 0) + return_code = -2; + cmd->executable = NULL; + return (return_code); } int ft_cmds_executor(t_list **cmds, t_list **env) diff --git a/main.c b/main.c index b67da56..41e02c6 100644 --- a/main.c +++ b/main.c @@ -6,7 +6,7 @@ /* By: cchauvet Date: Tue, 21 Feb 2023 15:12:26 +0100 Subject: [PATCH 2/3] fix: add '\n' pwd --- builtins/pwd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/builtins/pwd.c b/builtins/pwd.c index 65d3f00..aa7f39c 100644 --- a/builtins/pwd.c +++ b/builtins/pwd.c @@ -6,7 +6,7 @@ /* By: erey-bet +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/02/17 16:09:11 by erey-bet #+# #+# */ -/* Updated: 2023/02/21 14:34:50 by erey-bet ### ########.fr */ +/* Updated: 2023/02/21 15:11:38 by cchauvet ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,10 +17,10 @@ int pwd(int fd) char path[PATH_MAX]; if (getcwd(path, sizeof(path)) != NULL) - ft_putstr_fd(path, fd); + ft_putendl_fd(path, fd); else { - ft_putstr_fd("Error getcwd", fd); + ft_putendl_fd("Error getcwd", fd); return (1); } return (0); @@ -35,7 +35,7 @@ char *get_pwd(int fd) return (str); else { - ft_putstr_fd("Error getcwd", fd); + ft_putendl_fd("Error getcwd", fd); return (NULL); } } From d7032849d6d92a51c15c1d5aa8b7caf9e495463d Mon Sep 17 00:00:00 2001 From: Camille Chauvet Date: Tue, 21 Feb 2023 15:32:22 +0100 Subject: [PATCH 3/3] fix: minishell rework --- .execution.c.swp | Bin 20480 -> 0 bytes execution.c | 11 +++++++---- minishell.h | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) delete mode 100644 .execution.c.swp diff --git a/.execution.c.swp b/.execution.c.swp deleted file mode 100644 index 99fb472180b65abdc713e53a5aad1b4f6631ef53..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 20480 zcmeI2TZ|i58ONthn`TM_y+{-_5<1xxS+Cc-UOQ>jI+rG(qM{^iQ%I>Ot>d-FyF=`; zWsf(zO}IQXA`K9fA|%=eUIBqpp`!8tRRv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g(Kjx4rsGwP2$km@Wafk7wQ{Yd1kSE z#9Pda+`IQrIEZhq&D24q52-WI%qcx4Y%7_RVW+Nia3F{KrX1a|sWG{hSIEqdaThji z=xxbyyZ$3yIdpxL)qh!-#jY>R?A8~uW@4S|M0}OwmS|BH%g9WTO{B`zw`>C#^@D1o zSMx;wud}JS5vQNr@Mr4bLSBE#EQh;x_OgBCEggfG@e>(5)UL5<)k>l`UEG?VF6N5` zQMk1(zaVmh3%;Z#pr~z7=0OY z;=k+i1jfui4Dl;A*EjgVMK)o^U50^+ozbs7-H-te!bH@!uB(hplp;$Bn^Bh&Z4CEQ zTI*ZHPh&kYsHdZf9v{x25T%KdE^2=0ugKuAR+f}2l_Hb;k{@y}$>0*}=0Y31Yzu`& zmv`jz|4yFezX$U9KYD-vTb}!$gCD>t_!N8?Ho?vCZ_WZPz*+bTG~pl|00B3^M)(7E zUx0J)49Iq#2K%uJSOu&CRspMkRlq7>6|f3e1*`(^6a_eNijKI{*|j`?x|Fp3OQ-m4 zm3;li36RUHlYt|+J2-z!p84w2I9YbdIha1wUg_X%)kCnP_2dcV(sX%H>4&X~JbyPY z!}Q5)wbANwe6QbgMK1?cmOLgKNS9}o1+irdr^V_`V^m(I7v(D|ceyz~NVUe-bM%Drm4Pg>ijNtpnpb|JV=$EL@xGABy6PQ>SohU6|f3e1>RZ((xU&~PHAb8h{O7~Lfv7irvmB`xG~=$Vibb{U<8qOH ii9eLb74qyuhY_Vm=C+R}qD}{9XCVqhPNd7YpZ@?;BEDS! diff --git a/execution.c b/execution.c index 6bf9281..53eb881 100644 --- a/execution.c +++ b/execution.c @@ -6,7 +6,7 @@ /* By: cchauvet args[0], cmd->fd_out)); /* if (ft_strcmp(cmd->executable, "unset") == 0) */ /* return_code = (unset(env, cmd->args, cmd->fd_out)); */ - else if (ft_strcmp(cmd->executable, "echo") == 0) - return_code = (echo(cmd->fd_out, cmd->args + 1)); + /* else if (ft_strcmp(cmd->executable, "echo") == 0) */ + /* return_code = (echo(cmd->fd_out, cmd->args + 1)); */ else if (ft_strcmp(cmd->executable, "exit") == 0) return_code = -2; - cmd->executable = NULL; + if (return_code != -1) + cmd->executable = NULL; return (return_code); } diff --git a/minishell.h b/minishell.h index 531af7d..09dd7dd 100644 --- a/minishell.h +++ b/minishell.h @@ -6,7 +6,7 @@ /* By: cchauvet