From 916f2c3c501d6ccb5f2dae4b515fa34e1468af30 Mon Sep 17 00:00:00 2001 From: Camille Chauvet Date: Tue, 21 Feb 2023 22:38:00 +0100 Subject: [PATCH 1/2] fix: close fd --- builtins/.echo.c.swp | Bin 12288 -> 12288 bytes builtins/echo.c | 10 ++-------- cmd.c | 6 +----- execution.c | 7 ++++++- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/builtins/.echo.c.swp b/builtins/.echo.c.swp index 7361b426083084d6cefdbf78029e111509ed1d72..7ed1b8e933728625f8b75ac0705c35421192d146 100644 GIT binary patch delta 472 zcmXBQO(??w9LDkA-z@AUb5TTFl5H_ivF8wtjuN)+sz_3CXr=CF@bUP!H)`j8%4hGi7Q;< z6el>u9(FN~F$|#-9q^(SR=gNQ^0-C@X9fw&5h0E(tYZ-ogb_plgXl#k+TlYJ95Cal zMC2GrY-0nnn1TxynDJUH@_-!fkuDDK1tEnb64=2C<}r-{_~Ak|e%S8~x5y%cG|rJg z9BWv>-`1fbO)1Rjwa2=kqIEmU6DErS~+qHMPWiF1HqPtrq+O DZ**2% delta 881 zcmb`^O-NKx6u|K_&PR@pq_zkqic6s5jE(a?eAAmpB|*X%)k5e4EO6eu_X>iDP*Pfq zM35~4VHQQ?sumKps0VGTMFp+Gz*a4cAi^RNq5{E9|Codp5eOal-FvuS=W_4V=+tQ1 z)s74uRCb>(M7ziv^GEf}rQX&)~H@dJDNhGk)A~KH`xQ98+;wq+b ztVL=vOtKTb$Y2|ySWSwo;4?nqBbG3amw1MUxQpAkg&UZ`IF6zVn-Iflv&cIv;yNy1 zqPZqALUI86F@!R5=)o3rB7r!*ZV>r^MLfr2T*GCY!UzUY!Vct+MFKH==k1s9>kl5_ zPLgI8HxpqbHV~`rX@t@PuWIR)V$t@C|9ea?dVZ3BMzFrZYd2f# z|Gf3zs_43Hl$Z!7GAAS9+n&vl`bu^>tmWpKj<5F&Dddz=htGPIG2e5Pp&4dDGYW>T z48ze%j%6u#Qu*in$-G-1&Ua^bH{u`rbf@2POuJsrYpGq0Q02kB`@-}2D@{KE@@=)Q diff --git a/builtins/echo.c b/builtins/echo.c index 32c495b..8a3800f 100644 --- a/builtins/echo.c +++ b/builtins/echo.c @@ -6,11 +6,7 @@ /* By: erey-bet +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/02/17 13:09:08 by erey-bet #+# #+# */ -<<<<<<< HEAD -/* Updated: 2023/02/21 21:45:38 by cchauvet ### ########.fr */ -======= -/* Updated: 2023/02/21 22:09:55 by erey-bet ### ########.fr */ ->>>>>>> 1fdc51a668e616de94c33d5b3b1e9cb51182916d +/* Updated: 2023/02/21 22:15:27 by cchauvet ### ########.fr */ /* */ /* ************************************************************************** */ @@ -49,7 +45,6 @@ int check_argument(char *str, int *check, int i) return (i); } - char *conca(char **strs) { int len; @@ -60,7 +55,7 @@ char *conca(char **strs) i = -1; len = 0; while (strs[++i] != NULL) - len += strlen(strs[i]) + 2; + len += ft_strlen(strs[i]) + 2; str = (char *) ft_calloc(len + 1, sizeof(char)); if (str == NULL) return NULL; @@ -74,7 +69,6 @@ char *conca(char **strs) return (str); } - int echo(int fd, char **strs) { int check; diff --git a/cmd.c b/cmd.c index a3de42c..2609718 100644 --- a/cmd.c +++ b/cmd.c @@ -6,7 +6,7 @@ /* By: cchauvet args); if (content->executable != NULL) free(content->executable); - if (content->fd_in > 2) - close(content->fd_in); - if (content->fd_out > 2) - close(content->fd_in); free(content); } diff --git a/execution.c b/execution.c index 410f994..d833c55 100644 --- a/execution.c +++ b/execution.c @@ -6,12 +6,13 @@ /* By: cchauvet static char *ft_get_executable_path(char *executable_name, t_list **env) { @@ -158,6 +159,10 @@ int ft_cmds_executor(t_data *data, t_list **cmds) ft_eprintf("minishell: malloc failed\n"); return (1); } + if (content->fd_in > 2) + close(content->fd_in); + if (content->fd_out > 2) + close(content->fd_out); set_value_by_key("?", return_value, data->env); current = current->next; } From 76bc8fbfd8d5413e8f6e4f3eb6ec00db0fa3c884 Mon Sep 17 00:00:00 2001 From: Camille Chauvet Date: Tue, 21 Feb 2023 23:12:16 +0100 Subject: [PATCH 2/2] fix: quoted split work now --- builtins/.echo.c.swp | Bin 12288 -> 0 bytes utils/ft_is_in_quote.c | 6 +++--- 2 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 builtins/.echo.c.swp diff --git a/builtins/.echo.c.swp b/builtins/.echo.c.swp deleted file mode 100644 index 7ed1b8e933728625f8b75ac0705c35421192d146..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2O^6&t7=|l?XcL(2s%4%dV6Xz<<9o5-94L( zo4BG8!HeR}7{Oz1BIre83;_`@dh;SG9tA-?2#O%SUsd#fL`y8i8P9yw5%cD>;AQm-o) zWu+Z%9{pk}Se=Du}Am?<`gP&BxkS>wtA&rw)vwtB@I$#~J4p;}Q1J(iSfOWt+U>&#t9q?L=eS0%w{acVc{{R0}vWEBXWb9cm2Cm$} z*aEm0d@;t@S&#)^-_F>p-~xCKDDWgW0qy~R?q%!`@H_Y%d7v#Vg_=z+2 zF}Mug25*8M2tgU_17qNqTN(QSd=I_@*T7Zq0k{k8*X>bCR!F}K_`1>pP z27CpsgKOYZa0y%luY>b|_TntCk9EL0U>&dy{0|*CU#K!3%D5K>B3H{FW}H5M%Q+?C zg{N0gUuD&T3Sz$KsUU{}wfiN3Z}LJ>pqNH8kAE*Vh_pi~b5R_UAU_kTSmxTTl9-qc zCQ8DgR@D}{ala$|g*-yq@!WDRCegWeiv~7SvDhq$c8g-qbW~Rg(~Q};5;I5uL+6k{ zZ&3y@^_9e=ZY&9X7sMHXl2SJg_kRk1*!1qWpf)E9GAuphc z0J4Isw4jHQN7Ss1BZp|E#vd9Kt+xj)lpS6TEE=z_3}~u+6BB1=Ygu%{&8-3i^^;vR z()W^uqY`0N@N1oO?%3yWW*Qik}s-_s95ywv+JC>MJc4)5Ta8Ns{v~8G8 z%nTxRP2|ji^E9FFb-PP`4hzFvI7yLuK`ym*M4o2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