diff --git a/.main.c.swp b/.main.c.swp new file mode 100644 index 0000000..35e105d Binary files /dev/null and b/.main.c.swp differ diff --git a/.minishell.h.swp b/.minishell.h.swp deleted file mode 100644 index 6f50c2d..0000000 Binary files a/.minishell.h.swp and /dev/null differ diff --git a/Makefile b/Makefile index f88bd84..d33b5a0 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -UTILS_SRC = utils/ft_is_in_quote.c utils/ft_strncpy.c utils/ft_strreplace.c utils/ft_strnchr.c utils/ft_getstr.c +UTILS_SRC = utils/ft_is_in_quote.c utils/ft_strncpy.c utils/ft_strreplace.c utils/ft_strnchr.c utils/ft_getstr.c utils/ft_printn.c SRCS = ${UTILS_SRC} main.c file.c infile.c outfile.c heredoc.c syntatics.c ft_split_quoted.c env.c execution.c OBJS = ${SRCS:.c=.o} diff --git a/builtin/env.c b/builtin/env.c new file mode 100644 index 0000000..f97a271 --- /dev/null +++ b/builtin/env.c @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* env.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet content); + current = current->next; + } + return (0); +} diff --git a/builtin/export.c b/builtin/export.c new file mode 100644 index 0000000..ef2ba11 --- /dev/null +++ b/builtin/export.c @@ -0,0 +1,40 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* export.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet content, '=') + 1; + key = ft_strndup(current->content, + ft_strlen(current->content) - ft_strlen(value)); + if (key == NULL) + { + ft_lstclear(env_lst, env_del); + return (1); + } + ft_printf("declare -x %s=\"%s\"\n", key, value); + free(key); + current = current->next; + } + ft_lstclear(env_lst, env_del); + return (0); +} diff --git a/env.c b/env.c index 851a496..9b79576 100644 --- a/env.c +++ b/env.c @@ -6,57 +6,17 @@ /* By: erey-bet +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/02/02 14:39:56 by erey-bet #+# #+# */ -/* Updated: 2023/02/14 07:32:43 by cchauvet ### ########.fr */ +/* Updated: 2023/02/14 15:21:28 by cchauvet ### ########.fr */ /* */ /* ************************************************************************** */ +#include "libftx/libftx.h" #include "minishell.h" +#include "utils/utils.h" -int get_index(char *s, char c) +void env_del(void *content) { - int i; - - i = -1; - while (s[++i]) - if (s[i] == c) - return (i); - return (-1); -} - -void print_export(t_list **head, int fd) -{ - t_list *current; - char *ctn; - int v; - - current = *head; - while (current != NULL) - { - ctn = current->content; - if (*(ft_strchr(ctn, '=') - 1) != '_') - { - v = get_index(ctn, '='); - write(fd, "declare -x ", 11); - write(fd, ctn, v + 1); - write(fd, "\"", 1); - ft_putstr_fd(ctn + v + 1, fd); - write(fd, "\"\n", 2); - } - current = current->next; - } -} - -void print_env(t_list **head, int fd) -{ - t_list *current; - - current = *head; - while (current != NULL) - { - ft_putstr_fd(current->content, fd); - write(fd, "\n", 1); - current = current->next; - } + (void) content; } int strcmp_alphabet(char *s1, char *s2) @@ -139,22 +99,6 @@ char *get_value_by_index(int index, t_list **head) return (NULL); } -int is_start(char *big, char *little) -{ - int i; - - i = 0; - while (big[i]) - { - if (little[i] != big[i]) - return (0); - i++; - if (!little[i]) - return (1); - } - return (0); -} - char *get_value_by_key(char *key, t_list **head) { t_list *current; @@ -162,13 +106,39 @@ char *get_value_by_key(char *key, t_list **head) current = *head; while (current != NULL) { - if (is_start(current->content, key)) + if (ft_strncmp(current->content, key, ft_strlen(key))) return (ft_strchr(current->content, '=') + 1); current = current->next; } return (NULL); } +int set_value_by_key(t_list **env, char *key, char *value) +{ + t_list *current; + char *temp; + + current = *env; + while (current != NULL) + { + if (!ft_strncmp(key, current->content, ft_strlen(current->content))) + { + temp = current->content; + current->content = ft_strreplace(temp, value, + ft_strnchr(temp, '=') + 1, + ft_strlen(temp) - (ft_strnchr(temp, '=') - 1)); + free(temp); + if (current->content == NULL) + { + ft_eprintf("minishell: malloc failed"); + return (1); + } + } + current = current->next; + } + return (0); +} + t_list **init_env(char **env) { t_list **head; @@ -183,12 +153,3 @@ t_list **init_env(char **env) add_sort(head, env[i]); return (head); } - -/*int main(int argc, char *argv[], char **env) -{ - (void)argc; - (void)argv; - ft_putstr_fd(get_value_index(10, init_env(env)), 1); - //print_env(init_env(env), 1); - return (0); -}*/ diff --git a/env.o b/env.o new file mode 100644 index 0000000..c59381d Binary files /dev/null and b/env.o differ diff --git a/execution.c b/execution.c index 20c29e2..eb6a2ed 100644 --- a/execution.c +++ b/execution.c @@ -8,10 +8,11 @@ static char *ft_get_variable(char **env, char *variable) size_t i; i = 0; - while (env[i] == NULL) + while (env[i] != NULL) { - if (ft_strncmp(variable, env[1], ft_strlen(variable))) - return (ft_strchr(env[1], '=') + 1); + if (ft_strncmp(variable, env[i], ft_strlen(variable)) == 0) + return (ft_strchr(env[i], '=') + 1); + i++; } return (NULL); } @@ -19,11 +20,13 @@ static char *ft_get_variable(char **env, char *variable) static char *ft_get_executable_path(char *executable_name, char **env) { char *path; + char *temp; char **tab; size_t i; + path = NULL; if (executable_name[0] == '.' || executable_name[0] == '/') - path = executable_name; + path = ft_strdup(executable_name); else { tab = ft_split(ft_get_variable(env, "PATH"), ':'); @@ -32,14 +35,25 @@ static char *ft_get_executable_path(char *executable_name, char **env) i = 0; while (tab[i] != NULL) { - if (access(tab[i], X_OK) == 0) + temp = ft_strmerger(3, tab[i], "/", executable_name); + if (temp == NULL) { - path = ft_strmerger(3, tab[i], "/", executable_name); + ft_freer_tab_ultimate(1, tab); free(executable_name); + ft_eprintf("minishell: malloc failed\n"); + } + if (access(temp, X_OK) == 0) + { + path = temp; break ; } + free(temp); i++; } + if (path == NULL) + { + ft_eprintf("%s: command not found\n", executable_name); + } ft_freer_tab_ultimate(1, tab); } return (path); @@ -48,7 +62,6 @@ static char *ft_get_executable_path(char *executable_name, char **env) static int ft_excutor(t_cmd *cmd, char **env) { int pid; - char *executable; int return_value; pid = fork(); @@ -58,7 +71,7 @@ static int ft_excutor(t_cmd *cmd, char **env) { dup2(cmd->fd_out, 1); dup2(cmd->fd_in, 0); - execve(executable, cmd->args, env); + execve(cmd->executable, cmd->args, env); } else waitpid(pid, &return_value, 0); @@ -72,16 +85,24 @@ int ft_cmds_executor(t_list **cmds, char **env) int fds[2]; current = *cmds; - while (current->next != NULL) + while (current != NULL) { - if (pipe(fds) == -1) + content = current->content; + if (current->next != NULL) { - ft_eprintf("minishell: pipe failed"); - return (1); + if (pipe(fds) == -1) + { + ft_eprintf("minishell: pipe failed\n"); + return (1); + } + content->fd_out = fds[1]; + ((t_cmd *) current->next->content)->fd_in = fds[0]; } - content->fd_out = fds[1]; - ((t_cmd *) current->next)->fd_in = fds[0]; - ft_excutor(content, env); + content->executable = ft_get_executable_path(content->executable, env); + if (content->executable != NULL) + ft_excutor(content, env); + close(content->fd_in); + close(content->fd_out); current = current->next; } return (0); diff --git a/execution.o b/execution.o new file mode 100644 index 0000000..6a78a99 Binary files /dev/null and b/execution.o differ diff --git a/file.o b/file.o new file mode 100644 index 0000000..fdeafb9 Binary files /dev/null and b/file.o differ diff --git a/ft_split_quoted.o b/ft_split_quoted.o new file mode 100644 index 0000000..377f37d Binary files /dev/null and b/ft_split_quoted.o differ diff --git a/heredoc.o b/heredoc.o new file mode 100644 index 0000000..985bf76 Binary files /dev/null and b/heredoc.o differ diff --git a/infile.o b/infile.o new file mode 100644 index 0000000..939685e Binary files /dev/null and b/infile.o differ diff --git a/libftx/extra/extra.a b/libftx/extra/extra.a new file mode 100644 index 0000000..b05f88c Binary files /dev/null and b/libftx/extra/extra.a differ diff --git a/libftx/extra/ft_contain_only.o b/libftx/extra/ft_contain_only.o new file mode 100644 index 0000000..4b885eb Binary files /dev/null and b/libftx/extra/ft_contain_only.o differ diff --git a/libftx/extra/ft_freer.o b/libftx/extra/ft_freer.o new file mode 100644 index 0000000..cf50d16 Binary files /dev/null and b/libftx/extra/ft_freer.o differ diff --git a/libftx/extra/ft_is_in.o b/libftx/extra/ft_is_in.o new file mode 100644 index 0000000..9ac5767 Binary files /dev/null and b/libftx/extra/ft_is_in.o differ diff --git a/libftx/extra/ft_random_generator.o b/libftx/extra/ft_random_generator.o new file mode 100644 index 0000000..a64dbb0 Binary files /dev/null and b/libftx/extra/ft_random_generator.o differ diff --git a/libftx/extra/ft_strchri.o b/libftx/extra/ft_strchri.o new file mode 100644 index 0000000..230ddca Binary files /dev/null and b/libftx/extra/ft_strchri.o differ diff --git a/libftx/extra/ft_strcmp.o b/libftx/extra/ft_strcmp.o new file mode 100644 index 0000000..0ed8391 Binary files /dev/null and b/libftx/extra/ft_strcmp.o differ diff --git a/libftx/extra/ft_strfjoin.o b/libftx/extra/ft_strfjoin.o new file mode 100644 index 0000000..1a4743d Binary files /dev/null and b/libftx/extra/ft_strfjoin.o differ diff --git a/libftx/extra/ft_strgen.o b/libftx/extra/ft_strgen.o new file mode 100644 index 0000000..261ec45 Binary files /dev/null and b/libftx/extra/ft_strgen.o differ diff --git a/libftx/extra/ft_strmerger.o b/libftx/extra/ft_strmerger.o new file mode 100644 index 0000000..3526a30 Binary files /dev/null and b/libftx/extra/ft_strmerger.o differ diff --git a/libftx/extra/ft_strndup.o b/libftx/extra/ft_strndup.o new file mode 100644 index 0000000..e773a90 Binary files /dev/null and b/libftx/extra/ft_strndup.o differ diff --git a/libftx/extra/ft_swap.o b/libftx/extra/ft_swap.o new file mode 100644 index 0000000..bc573bd Binary files /dev/null and b/libftx/extra/ft_swap.o differ diff --git a/libftx/extra/ft_tabrealloc.o b/libftx/extra/ft_tabrealloc.o new file mode 100644 index 0000000..973478b Binary files /dev/null and b/libftx/extra/ft_tabrealloc.o differ diff --git a/libftx/extra/ft_ultoa_base.o b/libftx/extra/ft_ultoa_base.o new file mode 100644 index 0000000..155c917 Binary files /dev/null and b/libftx/extra/ft_ultoa_base.o differ diff --git a/libftx/gnl/get_next_line.a b/libftx/gnl/get_next_line.a new file mode 100644 index 0000000..7d3ebe9 Binary files /dev/null and b/libftx/gnl/get_next_line.a differ diff --git a/libftx/gnl/get_next_line.o b/libftx/gnl/get_next_line.o new file mode 100644 index 0000000..46741e0 Binary files /dev/null and b/libftx/gnl/get_next_line.o differ diff --git a/libftx/libft/ft_atoi.o b/libftx/libft/ft_atoi.o new file mode 100644 index 0000000..749693b Binary files /dev/null and b/libftx/libft/ft_atoi.o differ diff --git a/libftx/libft/ft_bzero.o b/libftx/libft/ft_bzero.o new file mode 100644 index 0000000..77fec06 Binary files /dev/null and b/libftx/libft/ft_bzero.o differ diff --git a/libftx/libft/ft_calloc.o b/libftx/libft/ft_calloc.o new file mode 100644 index 0000000..a17b032 Binary files /dev/null and b/libftx/libft/ft_calloc.o differ diff --git a/libftx/libft/ft_isalnum.o b/libftx/libft/ft_isalnum.o new file mode 100644 index 0000000..717e49b Binary files /dev/null and b/libftx/libft/ft_isalnum.o differ diff --git a/libftx/libft/ft_isalpha.o b/libftx/libft/ft_isalpha.o new file mode 100644 index 0000000..fbdbbb4 Binary files /dev/null and b/libftx/libft/ft_isalpha.o differ diff --git a/libftx/libft/ft_isascii.o b/libftx/libft/ft_isascii.o new file mode 100644 index 0000000..67137be Binary files /dev/null and b/libftx/libft/ft_isascii.o differ diff --git a/libftx/libft/ft_isdigit.o b/libftx/libft/ft_isdigit.o new file mode 100644 index 0000000..6a91375 Binary files /dev/null and b/libftx/libft/ft_isdigit.o differ diff --git a/libftx/libft/ft_isprint.o b/libftx/libft/ft_isprint.o new file mode 100644 index 0000000..bde8775 Binary files /dev/null and b/libftx/libft/ft_isprint.o differ diff --git a/libftx/libft/ft_itoa.o b/libftx/libft/ft_itoa.o new file mode 100644 index 0000000..c75cfcb Binary files /dev/null and b/libftx/libft/ft_itoa.o differ diff --git a/libftx/libft/ft_lstadd_back.o b/libftx/libft/ft_lstadd_back.o new file mode 100644 index 0000000..1cf3242 Binary files /dev/null and b/libftx/libft/ft_lstadd_back.o differ diff --git a/libftx/libft/ft_lstadd_front.o b/libftx/libft/ft_lstadd_front.o new file mode 100644 index 0000000..8f727c5 Binary files /dev/null and b/libftx/libft/ft_lstadd_front.o differ diff --git a/libftx/libft/ft_lstclear.o b/libftx/libft/ft_lstclear.o new file mode 100644 index 0000000..236b952 Binary files /dev/null and b/libftx/libft/ft_lstclear.o differ diff --git a/libftx/libft/ft_lstdelone.o b/libftx/libft/ft_lstdelone.o new file mode 100644 index 0000000..cd26ada Binary files /dev/null and b/libftx/libft/ft_lstdelone.o differ diff --git a/libftx/libft/ft_lstiter.o b/libftx/libft/ft_lstiter.o new file mode 100644 index 0000000..266717a Binary files /dev/null and b/libftx/libft/ft_lstiter.o differ diff --git a/libftx/libft/ft_lstlast.o b/libftx/libft/ft_lstlast.o new file mode 100644 index 0000000..3d210a2 Binary files /dev/null and b/libftx/libft/ft_lstlast.o differ diff --git a/libftx/libft/ft_lstmap.o b/libftx/libft/ft_lstmap.o new file mode 100644 index 0000000..3122efb Binary files /dev/null and b/libftx/libft/ft_lstmap.o differ diff --git a/libftx/libft/ft_lstnew.o b/libftx/libft/ft_lstnew.o new file mode 100644 index 0000000..825ded9 Binary files /dev/null and b/libftx/libft/ft_lstnew.o differ diff --git a/libftx/libft/ft_lstsize.o b/libftx/libft/ft_lstsize.o new file mode 100644 index 0000000..dc114d8 Binary files /dev/null and b/libftx/libft/ft_lstsize.o differ diff --git a/libftx/libft/ft_memchr.o b/libftx/libft/ft_memchr.o new file mode 100644 index 0000000..f1c3326 Binary files /dev/null and b/libftx/libft/ft_memchr.o differ diff --git a/libftx/libft/ft_memcmp.o b/libftx/libft/ft_memcmp.o new file mode 100644 index 0000000..6b0da03 Binary files /dev/null and b/libftx/libft/ft_memcmp.o differ diff --git a/libftx/libft/ft_memcpy.o b/libftx/libft/ft_memcpy.o new file mode 100644 index 0000000..98e41b8 Binary files /dev/null and b/libftx/libft/ft_memcpy.o differ diff --git a/libftx/libft/ft_memmove.o b/libftx/libft/ft_memmove.o new file mode 100644 index 0000000..71f160b Binary files /dev/null and b/libftx/libft/ft_memmove.o differ diff --git a/libftx/libft/ft_memset.o b/libftx/libft/ft_memset.o new file mode 100644 index 0000000..2737808 Binary files /dev/null and b/libftx/libft/ft_memset.o differ diff --git a/libftx/libft/ft_putchar_fd.o b/libftx/libft/ft_putchar_fd.o new file mode 100644 index 0000000..58df18e Binary files /dev/null and b/libftx/libft/ft_putchar_fd.o differ diff --git a/libftx/libft/ft_putendl_fd.o b/libftx/libft/ft_putendl_fd.o new file mode 100644 index 0000000..50cfa1e Binary files /dev/null and b/libftx/libft/ft_putendl_fd.o differ diff --git a/libftx/libft/ft_putnbr_fd.o b/libftx/libft/ft_putnbr_fd.o new file mode 100644 index 0000000..17d4db5 Binary files /dev/null and b/libftx/libft/ft_putnbr_fd.o differ diff --git a/libftx/libft/ft_putstr_fd.o b/libftx/libft/ft_putstr_fd.o new file mode 100644 index 0000000..f795861 Binary files /dev/null and b/libftx/libft/ft_putstr_fd.o differ diff --git a/libftx/libft/ft_split.o b/libftx/libft/ft_split.o new file mode 100644 index 0000000..dbc3910 Binary files /dev/null and b/libftx/libft/ft_split.o differ diff --git a/libftx/libft/ft_strchr.o b/libftx/libft/ft_strchr.o new file mode 100644 index 0000000..dcad448 Binary files /dev/null and b/libftx/libft/ft_strchr.o differ diff --git a/libftx/libft/ft_strdup.o b/libftx/libft/ft_strdup.o new file mode 100644 index 0000000..82b9840 Binary files /dev/null and b/libftx/libft/ft_strdup.o differ diff --git a/libftx/libft/ft_striteri.o b/libftx/libft/ft_striteri.o new file mode 100644 index 0000000..8ecd945 Binary files /dev/null and b/libftx/libft/ft_striteri.o differ diff --git a/libftx/libft/ft_strjoin.o b/libftx/libft/ft_strjoin.o new file mode 100644 index 0000000..ec8e4ff Binary files /dev/null and b/libftx/libft/ft_strjoin.o differ diff --git a/libftx/libft/ft_strlcat.o b/libftx/libft/ft_strlcat.o new file mode 100644 index 0000000..01a3aa5 Binary files /dev/null and b/libftx/libft/ft_strlcat.o differ diff --git a/libftx/libft/ft_strlcpy.o b/libftx/libft/ft_strlcpy.o new file mode 100644 index 0000000..f3e39eb Binary files /dev/null and b/libftx/libft/ft_strlcpy.o differ diff --git a/libftx/libft/ft_strlen.o b/libftx/libft/ft_strlen.o new file mode 100644 index 0000000..3c92240 Binary files /dev/null and b/libftx/libft/ft_strlen.o differ diff --git a/libftx/libft/ft_strmapi.o b/libftx/libft/ft_strmapi.o new file mode 100644 index 0000000..c36b41b Binary files /dev/null and b/libftx/libft/ft_strmapi.o differ diff --git a/libftx/libft/ft_strncmp.o b/libftx/libft/ft_strncmp.o new file mode 100644 index 0000000..5af8cfb Binary files /dev/null and b/libftx/libft/ft_strncmp.o differ diff --git a/libftx/libft/ft_strnstr.o b/libftx/libft/ft_strnstr.o new file mode 100644 index 0000000..80ab0e1 Binary files /dev/null and b/libftx/libft/ft_strnstr.o differ diff --git a/libftx/libft/ft_strrchr.o b/libftx/libft/ft_strrchr.o new file mode 100644 index 0000000..4b6be03 Binary files /dev/null and b/libftx/libft/ft_strrchr.o differ diff --git a/libftx/libft/ft_strtrim.o b/libftx/libft/ft_strtrim.o new file mode 100644 index 0000000..b08e9b2 Binary files /dev/null and b/libftx/libft/ft_strtrim.o differ diff --git a/libftx/libft/ft_substr.o b/libftx/libft/ft_substr.o new file mode 100644 index 0000000..982ffda Binary files /dev/null and b/libftx/libft/ft_substr.o differ diff --git a/libftx/libft/ft_tolower.o b/libftx/libft/ft_tolower.o new file mode 100644 index 0000000..a1107d9 Binary files /dev/null and b/libftx/libft/ft_tolower.o differ diff --git a/libftx/libft/ft_toupper.o b/libftx/libft/ft_toupper.o new file mode 100644 index 0000000..a7c9dbf Binary files /dev/null and b/libftx/libft/ft_toupper.o differ diff --git a/libftx/libft/libft.a b/libftx/libft/libft.a new file mode 100644 index 0000000..c0094b0 Binary files /dev/null and b/libftx/libft/libft.a differ diff --git a/libftx/libftx.a b/libftx/libftx.a new file mode 100644 index 0000000..0afbcc0 Binary files /dev/null and b/libftx/libftx.a differ diff --git a/libftx/printf/ft_dprintX.o b/libftx/printf/ft_dprintX.o new file mode 100644 index 0000000..f17c096 Binary files /dev/null and b/libftx/printf/ft_dprintX.o differ diff --git a/libftx/printf/ft_dprintarg.o b/libftx/printf/ft_dprintarg.o new file mode 100644 index 0000000..2bbcb2d Binary files /dev/null and b/libftx/printf/ft_dprintarg.o differ diff --git a/libftx/printf/ft_dprintflag.o b/libftx/printf/ft_dprintflag.o new file mode 100644 index 0000000..920afb5 Binary files /dev/null and b/libftx/printf/ft_dprintflag.o differ diff --git a/libftx/printf/ft_dprintl_base.o b/libftx/printf/ft_dprintl_base.o new file mode 100644 index 0000000..0f75c8d Binary files /dev/null and b/libftx/printf/ft_dprintl_base.o differ diff --git a/libftx/printf/ft_dprintptr.o b/libftx/printf/ft_dprintptr.o new file mode 100644 index 0000000..5b13694 Binary files /dev/null and b/libftx/printf/ft_dprintptr.o differ diff --git a/libftx/printf/ft_dprintstrtab.o b/libftx/printf/ft_dprintstrtab.o new file mode 100644 index 0000000..b2635fb Binary files /dev/null and b/libftx/printf/ft_dprintstrtab.o differ diff --git a/libftx/printf/ft_dprintul.o b/libftx/printf/ft_dprintul.o new file mode 100644 index 0000000..85d8866 Binary files /dev/null and b/libftx/printf/ft_dprintul.o differ diff --git a/libftx/printf/ft_dprintul_base.o b/libftx/printf/ft_dprintul_base.o new file mode 100644 index 0000000..ca970dc Binary files /dev/null and b/libftx/printf/ft_dprintul_base.o differ diff --git a/libftx/printf/ft_dprintx.o b/libftx/printf/ft_dprintx.o new file mode 100644 index 0000000..6bcdbb9 Binary files /dev/null and b/libftx/printf/ft_dprintx.o differ diff --git a/libftx/printf/ft_eprintf.o b/libftx/printf/ft_eprintf.o new file mode 100644 index 0000000..2b649ef Binary files /dev/null and b/libftx/printf/ft_eprintf.o differ diff --git a/libftx/printf/ft_isarg.o b/libftx/printf/ft_isarg.o new file mode 100644 index 0000000..28e9b52 Binary files /dev/null and b/libftx/printf/ft_isarg.o differ diff --git a/libftx/printf/ft_isdigit.o b/libftx/printf/ft_isdigit.o new file mode 100644 index 0000000..e6094e7 Binary files /dev/null and b/libftx/printf/ft_isdigit.o differ diff --git a/libftx/printf/ft_printf.a b/libftx/printf/ft_printf.a new file mode 100644 index 0000000..cbf2819 Binary files /dev/null and b/libftx/printf/ft_printf.a differ diff --git a/libftx/printf/ft_printf.o b/libftx/printf/ft_printf.o new file mode 100644 index 0000000..0a01be8 Binary files /dev/null and b/libftx/printf/ft_printf.o differ diff --git a/libftx/printf/ft_putchar_fd.o b/libftx/printf/ft_putchar_fd.o new file mode 100644 index 0000000..5554463 Binary files /dev/null and b/libftx/printf/ft_putchar_fd.o differ diff --git a/libftx/printf/ft_putstr_fd.o b/libftx/printf/ft_putstr_fd.o new file mode 100644 index 0000000..918d6ac Binary files /dev/null and b/libftx/printf/ft_putstr_fd.o differ diff --git a/libftx/printf/ft_skipflag.o b/libftx/printf/ft_skipflag.o new file mode 100644 index 0000000..6af9017 Binary files /dev/null and b/libftx/printf/ft_skipflag.o differ diff --git a/libftx/printf/ft_strlen.o b/libftx/printf/ft_strlen.o new file mode 100644 index 0000000..f576670 Binary files /dev/null and b/libftx/printf/ft_strlen.o differ diff --git a/libftx/printf/ft_vdprintf.o b/libftx/printf/ft_vdprintf.o new file mode 100644 index 0000000..b75be4f Binary files /dev/null and b/libftx/printf/ft_vdprintf.o differ diff --git a/main.c b/main.c index d0dd370..c6837d0 100644 --- a/main.c +++ b/main.c @@ -6,10 +6,10 @@ void ft_lstdel(void *ptr) t_cmd *content; content = (t_cmd *) ptr; - if (content->executable != NULL) - free(content->executable); if (content->args != NULL) ft_freer_tab_ultimate(1, content->args); + if (content->executable != NULL) + free(content->executable); free(content); } @@ -132,6 +132,7 @@ int ft_cmd_filler(t_list *element, char **args) i++; } content->args = args; + //pas free:10 content->executable = args[0]; return (0); } @@ -179,7 +180,6 @@ t_list **ft_parse_cmds(char *line) return (NULL); if (ft_cmds_fill(cmds, line) == 1) return (NULL); - ft_printf("%s\n", line); return (cmds); } @@ -204,5 +204,7 @@ int main(int ac, char **av, char **env) } ft_lstclear(data.env, env_del); ft_lstclear(cmds, ft_lstdel); + free(cmds); + free(data.env); return (0); } diff --git a/main.o b/main.o new file mode 100644 index 0000000..24722c1 Binary files /dev/null and b/main.o differ diff --git a/minishell b/minishell new file mode 100755 index 0000000..bd888d3 Binary files /dev/null and b/minishell differ diff --git a/minishell.h b/minishell.h index ea70e06..6bf32c9 100644 --- a/minishell.h +++ b/minishell.h @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* minishell.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet # include "../libftx/libftx.h" size_t ft_strncpy(char *dst, const char *src, size_t n); -int ft_is_in_quote(const char *str, size_t n); -char *ft_strreplace(char *str, const char *fill, size_t start, size_t stop); +int ft_is_in_quote(const char *str, size_t n); +char *ft_strreplace(char *str, const char *fill, + size_t start, size_t stop); ssize_t ft_strnchr(const char *str, char c); char *ft_getstr(const char *str, size_t n); +void ft_printn(const char *str, size_t n); #endif