diff --git a/lexer.c b/lexer.c index cc000c5..f7cb6dd 100644 --- a/lexer.c +++ b/lexer.c @@ -105,7 +105,7 @@ int replace_var(char **line, char *tmp, int tmp_i) while (i < len) tmp[tmp_i++] = value[i++]; tmp[tmp_i] = 0; - *line += i; + *line += ft_max(ft_strlen(var_name) + 1, i); return (tmp_i); } diff --git a/libft/Makefile b/libft/Makefile index d2dd293..19707b7 100755 --- a/libft/Makefile +++ b/libft/Makefile @@ -17,7 +17,7 @@ SRCS += mem/ft_bzero.c mem/ft_memset.c mem/ft_memchr.c mem/ft_memcpy.c \ SRCS += put/ft_putchar_fd.c put/ft_putnbr_fd.c put/ft_putendl_fd.c \ put/ft_putstr_fd.c -SRCS += nbr/ft_nbrlen.c nbr/ft_croissant.c nbr/ft_decroissant.c +SRCS += nbr/ft_nbrlen.c nbr/ft_croissant.c nbr/ft_decroissant.c nbr/ft_max.c SRCS += slist/ft_size.c slist/ft_new.c slist/ft_last.c \ slist/ft_add_back.c slist/ft_add_front.c slist/ft_delone.c \ diff --git a/libft/libft.h b/libft/libft.h index 2f6e695..65efa2d 100755 --- a/libft/libft.h +++ b/libft/libft.h @@ -56,6 +56,7 @@ size_t ft_ulen(unsigned int nbr); size_t ft_longbaselen(long nbr, size_t base); int ft_croissant(int a, int b); int ft_decroissant(int a, int b); +int ft_max(int a, int b); void *ft_memset(void *b, int c, size_t len); char *ft_strchr(const char *s, int c); diff --git a/libft/nbr/ft_max.c b/libft/nbr/ft_max.c new file mode 100644 index 0000000..050fa3a --- /dev/null +++ b/libft/nbr/ft_max.c @@ -0,0 +1,10 @@ +#include "../libft.h" + +int ft_max(int a, int b) +{ + if (a > b) + return (a); + else + return(b); +} + diff --git a/minishell.c b/minishell.c index 41116ff..dafa1cb 100644 --- a/minishell.c +++ b/minishell.c @@ -40,8 +40,8 @@ int caller(t_command *cmd) if (cmd->next) return (caller(cmd->next)); waitpid(pid, &status, 0); - if (WIFEXITED(status) && WEXITSTATUS(status)) - write(1, "\n", 1); + //if (WIFEXITED(status) && WEXITSTATUS(status)) + // write(1, "\n", 1); if (WIFSIGNALED(status)) printf("QUIT: %d\n", WTERMSIG(status)); if (cmd->fd[0])