From 2b66ce5bc39f81d705eac959c658ac92ef6c3667 Mon Sep 17 00:00:00 2001 From: Camille Chauvet Date: Tue, 21 Feb 2023 23:55:32 +0100 Subject: [PATCH 1/2] fix: "'''" --- main.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/main.c b/main.c index ad1eef6..0eaf7c9 100644 --- a/main.c +++ b/main.c @@ -6,12 +6,14 @@ /* By: cchauvet static char *ft_get_user_input(t_list **env) { @@ -43,14 +45,11 @@ static int ft_minishell(t_data *data, char *line) int infile; int outfile; + if (ft_syntatic_verif(line)) + return (1); line_clean = ft_normalizer(line); if (line_clean == NULL) return (1); - if (ft_syntatic_verif(line_clean)) - { - free(line_clean); - return (1); - } outfile = ft_outfile(line_clean); if (outfile == -2) { From 94f48602d1901cfd9ef72cbe4fd27123dd0ab8d2 Mon Sep 17 00:00:00 2001 From: Camille Chauvet Date: Wed, 22 Feb 2023 00:26:32 +0100 Subject: [PATCH 2/2] add: add ctrl + C support, but not work in heredoc --- builtins/.echo.c.swp | Bin 12288 -> 0 bytes execution.c | 4 ++-- main.c | 11 ++++++++--- syntatics.c | 8 +++----- 4 files changed, 13 insertions(+), 10 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 89a016f5cf36cec3f912805ad8d39f3434dfb6e9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2+iP4!9LFaGFJq0D`lK&TvXZ^uqsDFHtwj)O5itsG)^KumwtLLxY&d&1HTIIA z@vWc;q7?)$MSSz2`Xa4DrD$J#QvU$o1VI!9FE4(7GiUZvw>6UZP?%FbnK^TQ^PS)M z{$?6V&tl=JM;{Y2xgx`L3uB2#esf>iOz+Nr#hL3io$jg(>Cu(0;zM`mrb~{0xZQ2Z zWtnRPqoYq4!TfY7zwG&5rzu;l{9@N@g`VHZOSjq1xufUWQR{$pU>go}!$x*yoRv$( z0;$9%C&X=g=C&bdr&&dySO=^FSDORj${1Tm(z~L>ov0nVq>XNE zV;!&#SO=^F)&c8)b-+4c9k32q2do3u0qek3=zvpa?A$es)viPG`2TU=utCJn$rV0^AP%+RfM>;CJvPxB$+9v*2U!4tN`Q zK!O@L03HC-;4W|{_~{15egI#C^WZb^33v;<23`R#f(@_^8lVoI0f)c=un+77C6EB) z;788br{F_y3cL!sAOKmg2mE?HV?Tp$zy0M+Ahupj(#Eo1M3Q{W`n1ZA)b{E6CK1aE>jfW52( z)`5R_;CL#}cp$@W;EO~dxtDS2?(|r*ohW966C7TJ{!x}sd49N^HAd<2WykXqml595 zgi#r7Y2u)DSDZi=xEX=3$pVogJF2xLW5;{`n+!~=gw2g8Po6aA=sm4Ww<3q|HvENu8mMM5>e> znkrrzO-uS}u!e=>^MyDbV&C!0MFR<}%rg*j;Lqu3-&bO}-dNXGzdKm#vNzky&t^iWm3eR6EW`2EfpG zHZG>71ky&yvr)-0sAj2*c*<;KRT|FMURy_ZyJxL7de`EILQmtr!P>wo>5Yfdu!W)!I%y99o- zLvRN#BRIEGcS2dOh*F_c&KFAgQc;x3m2$CCm==p`!hGJ`TRIktp^u;H!gtZp6C=1E z+jdB>c&{jyD~0f)?_6D}nNkc69gK+c)CKpAUBau}KM>vPDv@->C=F;D!CvTAJEYcEM4pkl5!4@zZ&gjjRniq5A9ZwN f1pkwi39eL(Bzkn=!L|gA@L;P2ckH0x(B;|Rp)m-p diff --git a/execution.c b/execution.c index d833c55..a3fe3a7 100644 --- a/execution.c +++ b/execution.c @@ -6,7 +6,7 @@ /* By: cchauvet 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)); + return_code = (move_folder(cmd->args[1], 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) diff --git a/main.c b/main.c index 0eaf7c9..2cfb11c 100644 --- a/main.c +++ b/main.c @@ -10,10 +10,7 @@ /* */ /* ************************************************************************** */ -#include "libftx/libftx.h" #include "minishell.h" -#include "utils/utils.h" -#include static char *ft_get_user_input(t_list **env) { @@ -104,11 +101,19 @@ int main(int ac, char **av, char **env) #else +void ft_ctrlc(int num) +{ + rl_on_new_line(); + ft_putchar_fd('\n', 1); + rl_redisplay(); +} + int main(int ac, char **av, char **env) { t_data data; char *line; + signal(SIGINT, ft_ctrlc); data.env = init_env(env); if (data.env == NULL) return (1); diff --git a/syntatics.c b/syntatics.c index 85f9d0e..1b205ab 100644 --- a/syntatics.c +++ b/syntatics.c @@ -6,7 +6,7 @@ /* By: cchauvet 2 && (str[i] == '>' || str[i] == '<')) || (y > 1 && str[i] == '|')) { - ft_eprintf("minishell: to many %c in a row", str, str[i]); + ft_eprintf("minishell: too many %c in a row\n", str, str[i]); return (1); } i = i + y; @@ -96,8 +96,6 @@ int ft_empty_verif(const char *str) i = 0; while (str[i] == ' ') i++; - if (str[i] == '\0') - ft_eprintf("minishell: %s: command not found \n", str); return (str[i] == '\0'); }